Shorthand properties

Discussion in 'CSS' started by boba5555, Feb 8, 2009.

  1. #1
    Dear,
    I am interested in how shorthand properties work. Actually, I didn't know that
    font: 32px arial

    firefox accept, but
    font: 32px

    ignore. I have thought that it doesn't matter which properties (font-weight, font-size, font-family, etc...) you include and that it only matters how you order them. Is there some document that explain how all shorthand properties should be used? Is there some general rule about shorthand properties? Huh, it took me almost an hour to figure out that my css file has that kind of ignore :)
    Thank you in advance.

    the best regards,
     
    boba5555, Feb 8, 2009 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    While it has nothing to do with the specifications, if I'm changing my font-size I automatically use the shorthand version, but I always at least state weight size/line-height "desired font", "fallback font", family

    The reason for this is to make certain that if I change something upstream of it for style or weight I don't have to worry about it, you cant trust the default line-height behavior across browsers since they can give you wildly different values (gecko in particular is a complete ****tard about line-height), and of course you should ALWAYS have a fallback family.

    so if I'm going to change font size, I would use:

    font:normal 32px/36px arial,helvetcia,sans-serif;

    Just to make 100% certain I get what I want. It's not like it's enough 'extra code' to worry about anyways since

    font-size:32px;
    line-height:36px;

    is almost as many characters... and again, I NEVER declare a font-size without explicitly setting a line height.

    By the specification you should be able to omit or include whatever properties you want - but as we all know ALL of the browser makers tend to go their own directions and do whatever the hell they want when anything is left as "should" that doesn't mean they'll implement it that way.
     
    deathshadow, Feb 9, 2009 IP
  3. boba5555

    boba5555 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Is order of properties important? To be honest, I can't find that part in http://www.w3.org/TR/CSS2/fonts.html#propdef-font, so you give me a link where it is described? Thanks.
     
    boba5555, Feb 9, 2009 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    the order isn't important, just some have certain minimum properties necessary.

    People get so used to easy ones like "background" (which I never use without at least two properties) which let you just mention one thing, they get confused with ones like font or border which demand certain properties.

    The order of the fonts in the font-family declaration matter, and yes that's in the specs.
    The 13px/16px order is important as the first is always the font size while the second is always the line-height (if you write it that way).

    There is no necessary order for the things like font-variant, font-style, or font-weight.
     
    Stomme poes, Feb 9, 2009 IP
  5. boba5555

    boba5555 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Please, could you provide a link? Thanks. I have only found at http://www.w3.org/TR/CSS2/about.html#x0 that properties are first reset. I can't find that order is not important and that it is not important which of them are omitted. Also, I would like to find what are "minimum properties necessary" for each shorthand property.
     
    boba5555, Feb 9, 2009 IP
  6. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #6
    shallowink, Feb 9, 2009 IP
  7. boba5555

    boba5555 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Now I have found that font-size and font-family must be set in that order, but other properties could be omitted. Thanks a lot.
     
    boba5555, Feb 10, 2009 IP