Can someone explain the following to me;
In the following code all text is red in Firefox, Chrome and Opera. (code)
<html>
<head><title>HTML TEST</title></head>
<body>
Test One
<html style="color:red">Test Two</html>
</body>
</html>
Now I know in practice you shouldn’t add an html element inside the body tag, but what is making the browser change the colour of the text that is in body but not the second html?
If I add style=blue to the first html then all text is blue.
To reiterate – I understand this isn’t a practical problem, I just want to know what would make the browser act in such a way.
Use firebug for firefox or hit f12 in chrome to see how the browser is interpreting the code. In both Firefox and Chrome you will see there is only one
<html>tag. Interestingly, and in contrast to @Ragarokkr’s answer styling the outer tag sees to take precedence over the inner tag:Example