CSS Priority

Discussion in 'HTML' started by EYEBUZZ, Jan 29, 2004.

  1. EYEBUZZ

    EYEBUZZ Guest

    Hello,

    If you have a style sheet that is linked from an HTML document AND you have a
    duplicate style sheet actually on the page, meaning some names are the same but
    parameters are different, which takes priority (which does the browsers look
    too for instruction)?

    Does this change in different browsers/platforms?

    Thanks,
    Tim
     
    EYEBUZZ, Jan 29, 2004
    #1
    1. Advertising

  2. EYEBUZZ

    Spartanicus Guest

    (EYEBUZZ) wrote:

    >If you have a style sheet that is linked from an HTML document AND you have a
    >duplicate style sheet actually on the page, meaning some names are the same but
    >parameters are different, which takes priority (which does the browsers look
    >too for instruction)?


    http://www.w3.org/TR/CSS2/cascade.html#cascade

    --
    Spartanicus
     
    Spartanicus, Jan 29, 2004
    #2
    1. Advertising

  3. EYEBUZZ

    Dylan Parry Guest

    EYEBUZZ wrote:

    > Hello,
    >
    > If you have a style sheet that is linked from an HTML document AND you have a
    > duplicate style sheet actually on the page, meaning some names are the same but
    > parameters are different, which takes priority (which does the browsers look
    > too for instruction)?
    >
    > Does this change in different browsers/platforms?


    The last style defined always takes precedence, unless the !important
    keyword is used, which just complicated issues :)

    The general order is something like:

    External author's CSS - ie. <link... />
    Internal CSS - ie. within <style...></style>
    Inline styles - ie. <span style="..."></span>
    The user's own stylesheet

    HTH

    --
    Dylan Parry
    http://www.webpageworkshop.co.uk - FREE Web tutorials and references
     
    Dylan Parry, Jan 29, 2004
    #3
  4. Dylan Parry wrote:
    > The last style defined always takes precedence, unless the !important
    > keyword is used, which just complicated issues :)


    Nonsense. A stylesheet can have this:

    #bar {
    color : red;
    }
    ..foo {
    color : blue;
    }

    And this will be red, even though blue was defined after red:

    <div class="foo" id="bar">Red or blue, Neo?</div>
     
    Leif K-Brooks, Jan 29, 2004
    #4
  5. EYEBUZZ

    Dylan Parry Guest

    Leif K-Brooks wrote:

    > Dylan Parry wrote:
    >> The last style defined always takes precedence, unless the !important
    >> keyword is used, which just complicated issues :)

    >
    > Nonsense. A stylesheet can have this:
    >
    > #bar {
    > color : red;
    > }
    > .foo {
    > color : blue;
    > }
    >
    > And this will be red, even though blue was defined after red:
    >
    > <div class="foo" id="bar">Red or blue, Neo?</div>


    If you read the OP and my reply you will see that I was not referring to
    styles defined within the one sheet or to the complication of using a
    class and an id in the same element, but to the general overview - the
    last style being defined is the user's stylesheet, which takes precedence.

    --
    Dylan Parry
    http://www.webpageworkshop.co.uk - FREE Web tutorials and references
    Now playing: Yes - Give Love Each Day from "Magnification"
     
    Dylan Parry, Jan 29, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mosow

    aspnet_wp.exe priority

    mosow, Apr 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    390
    mosow
    Apr 16, 2004
  2. Replies:
    1
    Views:
    518
    Bruce Barker
    Nov 10, 2005
  3. Amil
    Replies:
    2
    Views:
    1,357
  4. Michael Laplante

    Question re: CSS priority

    Michael Laplante, Apr 21, 2005, in forum: HTML
    Replies:
    4
    Views:
    1,185
    Toby Inkster
    Apr 24, 2005
  5. Marcel Müller
    Replies:
    3
    Views:
    591
    Marcel Müller
    Apr 27, 2009
Loading...

Share This Page