Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3623600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:24:13+00:00 2026-05-18T23:24:13+00:00

Sometimes I see people apply global css styles to html , sometimes I see

  • 0

Sometimes I see people apply global css styles to html, sometimes I see them apply them to body, with both raw css and javascript.

Are there any differences between the two? Which is the standard to make a global css style? Is there anything I should know when picking between them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:24:13+00:00Added an answer on May 18, 2026 at 11:24 pm

    I’m assuming that “global page styling” here refers to things such as fonts, colors and backgrounds.

    Personally, I apply global page styling, for the most part, to body and the simple element selectors (p, h1, h2, h3..., input, img, etc). These elements are more closely related to the presentation of content of an HTML page to the user.

    My rationale for this is simple: the presentational attributes bgcolor, background, text, topmargin, leftmargin and others were given to the body element, not the html element. These attributes are now converted to their respective CSS rules with extremely low precedence in the cascade:

    The UA may choose to honor presentational attributes in an HTML source document. If so, these attributes are translated to the corresponding CSS rules with specificity equal to 0, and are treated as if they were inserted at the start of the author style sheet.

    Most if not all implementations I’m aware of will convert these to CSS rules on body, based on their HTML equivalents. Others such as link, alink and vlink will become a:link, a:active and a:visited rules respectively.

    Of course, it should be noted that CSS itself doesn’t really have any semantics to it per se, as it’s a styling language in itself which is completely separate from the content structure of an HTML document. Although the introduction to CSS2.1 covers the basics of styling an HTML document, note that the section calls itself non-normative (or informative); this means it doesn’t set any hard and fast rules for CSS implementers to follow. Instead, it simply provides information for readers.

    That said, certain styles may be applied to html to modify viewport behavior. For example, to hide the page scrollbars use:

    html {
        overflow: hidden;
    }
    

    You can also apply rules to both html and body for interesting effects; see the following questions for details and examples:

    • What's the difference in applying CSS to html, body, and *?
    • Applying a background to <html> and/or <body>

    Note that html is not the viewport; the viewport establishes an initial containing block in which html is situated. That initial containing block cannot be targeted with CSS, because in HTML, the root element is html.

    Note also that, technically, there is no difference between applying properties to html and body that are inherited by default, such as font-family and color.

    Last but not least, here is an excellent article that details the differences between html and body in terms of CSS. In summary (quoted from its first section):

    • The html and body elements are distinct block-level entities, in a
      parent/child relationship.
    • The html element’s height and width are controlled by the browser window.
    • It is the html element which has (by default) overflow:auto, causing
      scrollbars to appear when needed.
    • The body element is (by default) position:static, which means that
      positioned children of it are
      positioned relative to the html
      element’s coordinate system.
    • In almost all modern browsers, the built-in offset from the edge of the
      page is applied through a margin on
      the body element, not padding on the
      html element.

    As the root element, html is more closely associated with the browser viewport than body (which is why it says html has overflow: auto for scrollbars). Note however that the scrollbars are not necessarily generated by the html element itself. By default, it’s the viewport that generates these scrollbars; the values of overflow are simply transferred (or propagated) between body, html, and the viewport, depending on which values you set. The details of all this are covered in the CSS2.1 spec, which says:

    UAs must apply the ‘overflow’ property set on the root element to the viewport. When the root element is an HTML “HTML” element or an XHTML “html” element, and that element has an HTML “BODY” element or an XHTML “body” element as a child, user agents must instead apply the ‘overflow’ property from the first such child element to the viewport, if the value on the root element is ‘visible’. The ‘visible’ value when used for the viewport must be interpreted as ‘auto’. The element from which the value is propagated must have a used value for ‘overflow’ of ‘visible’.

    The last bullet point probably has its roots in the aforementioned topmargin and leftmargin attributes of the body element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes I see people using this to call function within a widget this.myFunction.apply(this, arguments);
Sometimes I see people use http://codepad.org as a way to quickly run/test their Perl
Sometimes I see @cc_on in JavaScript. What does it mean?
In code, I sometimes see people specify constants in hex format like this: const
Often I see a global object defined in javascript code to act as a
Thought I would throw this one out there and see what other people's experiences
I see this in other people's code sometimes: public void *foo() { ... }
Sometimes when I see a website I like or sites from respected people, I
I sometimes see people using the Activity.onAttachedToWindow method but personally, I did never use
I sometimes see messages like Process 12990 waits for ExclusiveLock on tuple (889,66) of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.