Mike
Mike

Reputation: 5816

When is Inline CSS executed?

When 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...?

Upvotes: 0

Views: 116

Answers (3)

jmar777
jmar777

Reputation: 39669

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/

Upvotes: 1

Joe
Joe

Reputation: 15802

It's applied as soon as the DOM element is created, before both DomReady and DomLoaded.

See http://jsfiddle.net/HZXXp/

Upvotes: 1

Tushar Ahirrao
Tushar Ahirrao

Reputation: 13145

When DOM parse your HTML file.It first parse your element then parse inline css. I think all browser follow this technique.

Upvotes: 0

Related Questions