1 Vote Vote

Attach Styles To Html Element

Posted by topdog 805 days ago Questions| html element html element All
Hi,

Is its standards compliant to attach styles to the html element?

Because in a webpage i am using:

CODE
<html style="background-color: #000; font-family: trebuchet ms, arial, sans-serif; font-size: 1em">


It renders correctly on firefox and konqueror, however, when I attempted to validate the page using totalvalidator I recieved this error:

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2 E620 The 'style' attribute is not valid for this tag here:
E621 The 'xmlns' attribute for this tag is missing:
W864 [WCAG v2 3.1.1 (A)] Use the 'lang' or 'xml:lang' attribute to denote the primary language of the
document:
<html style="background-color: #000; font-family: trebuchet ms, arial, sans-serif; font-size: 1em">

Does using style in the html element comply with the (x)html standard?

If not, is styling of the html element supported by the css standard, if i were to do it through css?

If styling the html element is supported, then would it be correct to use the following order of code to style the html element, if the styling is applied in the head element, after the html element:

CODE
<html>
    <head>
        <title>Nicholas Hill Studio - Fine Art to Fire your Imagination</title>
        <style>
        html {
        background-color: #000; font-family: trebuchet ms, arial, sans-serif; font-size: 1em
        }
        </style>
    </head>
</html>


If someone could provide a link to the standard to backup their comments, i'd be greatful.

Thanks for any help provided,

Matthew Millar
Discuss Bury


Who Voted for this Question