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?
The HTML tag style is useful for any website In the end, this will make it easier for you to build a website in a neat and well-structured way. If you also want to use external CSS files, use the link tag for that.
The style attribute is part of the Global Attributes, and can be used on any HTML element.
The <style> tag is used to define style information (CSS) for a document. Inside the <style> element you specify how HTML elements should render in a browser.
Any styling you want to do on the <body> should be put into your CSS. And, in fact, <body> is a great place to put all the CSS that should affect the document display as a whole: things like fonts and typography, text and background colors, and other other “default” styling.
Yes, it's OK to style the html
tag.
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.
It is very common practice. Used all the time on many websites including this one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With