0

In one of code academy lessons I found a CSS text like this;

html,body {
    font-family: 'Roboto', sans-serif;
    color: #404040;
    background-color: #eee;
}

is there a particular reason to use both "html,body" elements? Is there any bad affects to the page if the "html" element is removed? http://www.codecademy.com/courses/web-beginner-en-hk5qh/0/1?content_from=make-an-interactive-website%3Ajquery-dom-manipulation

2
  • There is: Some browsers won't apply to the body the style and only to the html, while others witll apply only to the body. And others that apply on both. Commented Apr 4, 2015 at 5:29
  • Not something like background color though, who needs that in the <head>... Commented Apr 4, 2015 at 9:14

1 Answer 1

2

The way I see it, it's more so redundancy than anything else.

When you code, you usually want to have many "backups" because each browser renders differently.

Some browsers (in the past) only support background colors in the HTML tag and others only in the body tag.

I know for sure that [Chrome, FireFox, Opera, IE] support backgrounds on the body tag.

Most developers have switched to only putting background on the body tag, but putting the background on the body and html tag comes from ancient practice.

Sign up to request clarification or add additional context in comments.

2 Comments

Do you have a source on this? Which browsers don't support background-color and on which elements?
I'm sorry, I couldn't find anything. In true honesty, the main browsers (Chrome, FireFox, Opera, and Internet Explorer) support background on simply body tag. Edited my answer with more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.