Adding styles to the <html> tag

Discussion in 'CSS' started by Goedele, Jun 7, 2007.

  1. #1
    One of our colleagues added a font size style to be applied on the HTML tag.

    I never saw this in any course or tutor on CSS, so I was wondering if this is W3C compliant and if it has any effect on the content ...

    :confused:
     
    Goedele, Jun 7, 2007 IP
  2. Katy

    Katy Moderator Staff

    Messages:
    3,490
    Likes Received:
    513
    Best Answers:
    7
    Trophy Points:
    355
    #2
    Katy, Jun 7, 2007 IP
  3. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #3
    In html, the only attributes allowed are lang and dir. Otherwise, there is nothing magical about the html element. It readily accepts styling, and all (to my knowledge) graphic browsers that support css allow it.

    It is not rare, for example, to see background images, colors, etc., used on both html and body elements.

    cheers,

    gary
     
    kk5st, Jun 7, 2007 IP
  4. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can apply styles to the HTML element; however it is not supported by every modern browser. Some browsers will allow you to apply some styles to it that others won't. As for fonts, it's best to apply them to the body instead. Not only do most Web designers expect them to be there, but it also happens to be the HTML element that contains all the page content anyway, so why would you even bother placing them elsewhere?
     
    Dan Schulz, Jun 8, 2007 IP
  5. Goedele

    Goedele Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for the answers all :)

    I agree with you Dan, that it is best to apply the base styles to the <body> tag.

    In the example that my colleague created, the style that was applied to the <html> tag (font-size) had an effect on the page ...

    I don't think it's common practice to apply styles to the HTML tag though.

    ;)
     
    Goedele, Jun 9, 2007 IP