Jump to content

richa.desai

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by richa.desai

  1.  

    You would just give the selector a higher a hierarchy ascendant parent, not swap stylesheets.

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    body p {
    color:yellow; 
    }
    
    html body p {
    color:green; 
    }
    
    p {
        font-family: verdana;
        font-size: 20px;
    color:red;
    }
    p {
    color:orange; /* placed below above declaration will override color red */
    }
    
    </style>
    </head>
    <body>
    
    <h1>My First CSS Example</h1>
    <p>This is a paragraph.</p>
    
    </body>
    </html>
    

    important can be avoided all the time, then why & when to use important

  2. As far as I'm aware !important is used to overwrite any other styling of the same type. It forces something to change regardless of what order it comes in, in the main html document. You can avoid using !important all the time by putting your style sheets in a certain order. For example if your customising css code in bootstrap.

     

    As you said, important can be avoided all the time, then why & when to use important

  3. Hi, in some code of w3schools, I found that there is !important attribute. But I didn't understand it's using. Guys, please help me to understand it. Thank you in advance. :ninja::X::boredom::umnik2::facepalm::sorry::sorry:

    !important is not preferable..there are other options available....still its used in w3schools webpages (in footer, thats where I have noticed)...there must be some strong reason...what is it?

×
×
  • Create New...