Hakan
Hakan

Reputation: 3885

Is it OK to style the <html> tag?

Sometimes you want two body backgrounds. One for the header and one for the footer. I accidentally discovered that it is possible to style the actual <html> tag.

HTML:

<html xmlns="http://www.w3.org/1999/xhtml">

CSS:

html {background:#000}

Is it OK to style this, or will it cause any problem?

Upvotes: 13

Views: 2828

Answers (3)

Dave
Dave

Reputation: 29121

Although it's debatable as to whether it's valid [see here]:

For HTML documents, however, we recommend that authors specify the background for the BODY element rather than the HTML element. ...

Many large sites still use it with seemingly consistent results.

Upvotes: 12

Craig White
Craig White

Reputation: 14002

It is very common practice. Used all the time on many websites including this one.

Upvotes: 3

Phrogz
Phrogz

Reputation: 303224

Yes, it's OK to style the html tag.

Upvotes: 3

Related Questions