When is Inline CSS executed?
W开发者_开发百科hen exactly is inline CSS like this applied?
<p style="background: blue; color: white;">A new background and
font color with inline CSS</p>
onDomReady, onDomLoaded, instantly...?
It's before onDomReady or onDomLoaded. Those style attributes will be set on the DOM node as the element is parsed, along with all of the other inline attributes. If you were to inspect the element in JavaScript in the very next line (w/out waiting for a load/ready event), you would see that the style properties are already set.
Edit: here's a quick jsfiddle demonstrating the immediate application of the style properties: http://jsfiddle.net/QZbMv/
It's applied as soon as the DOM element is created, before both DomReady and DomLoaded.
See http://jsfiddle.net/HZXXp/
When DOM parse your HTML file.It first parse your element then parse inline css. I think all browser follow this technique.
精彩评论