Grow your CSS skills. Land your dream job.

Stlying HTML Element

  • # July 27, 2009 at 4:17 pm

    I recently read an article that talked about applying style rules directly to the HTML element (font, background, etc.). The article then cited how the author uses the BODY element to replace the oh-so-common "wrapper" div. Is there any peril to applying styles to the HTML element? Do any browsers choke or fail to display styles applied in the HTML element?

    # July 27, 2009 at 4:43 pm

    if you are talking of the direct tag e.g. <body width="1000px" height="800px"> then HTML can do most of it, check what is allowed. but it is a hell of a lot better, easier & quicker to change if you use CSS

    welcome by the way

    # July 27, 2009 at 6:51 pm

    ikthius, Thanks for the welcome.

    I don’t think I was clear with my first post. I am talking about using css. Here’s a code block that should make my question a little clearer:

    html {
    background: #333 url(someimage.jpg) repeat-x top left;
    font: normal 1.2/1 arial, serif;
    }

    body {
    background: #fff;
    width: 950px;
    }

    My question is if anyone knows of any issues with support in any of the major browsers when applying these style rules directly to the html tag (element). I hope this is more clearly stated now.

    My biggest concern would be absolutely positioning the body element in this case. Normally I set the parent of any position: absolute element to position: relative. In this case that would be the html element and I wonder if this causes any browsers to have display issues (or any other related issues to styles in the html element).

    Rob
    # July 28, 2009 at 6:12 am

    you can style the HTML and BODY tag as you like. just don’t set them to height:10px; overflow:hidden; ;)

    # July 28, 2009 at 6:30 am

    I knew I had read this somewhere but it took me a while to track it down http://www.sitepoint.com/blogs/2009/02/11/styling-the-html-and-body-elements/

    # July 28, 2009 at 6:50 am

    Thanks so much apostrophe, I thought there might be some issues such as the ones outlined in that post. This was very informative and helped a lot. I don’t think I’m going to give up my trusty "wrapper" div just yet. :)

    "apostrophe" wrote:
    I knew I had read this somewhere but it took me a while to track it down http://www.sitepoint.com/blogs/2009/02/11/styling-the-html-and-body-elements/
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".