View Single Post
  #2 (permalink)  
Old July 27th, 2011, 04:32 PM
jmcpeak's Avatar
jmcpeak jmcpeak is offline
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

Howdy, Ashu2912.

You're seeing this behavior because of the markup. According to the HTML specification, an HTML document should have only one head element and one body element. Since you have two body elements, the browser uses the first body element and ignores the second element (but not it's content--in fact, the second element's content is appended to the first body). Because the second body element is ignored, the document's background doesn't change to yellow.

The same behavior is exhibited in the title elements. Your document has three head elements with three title elements. The browser uses the first title element and ignores the second and third.

To give you an idea of what the book was meaning, use this code:

Code:
<html>
<head>
    <title>Title 1</title>
</head>
<body>
<script>
    document.bgColor = "red";
    document.bgColor = "yellow";
</script>
</body>
</html>

Last edited by jmcpeak; July 27th, 2011 at 04:38 PM..
Reply With Quote
The Following User Says Thank You to jmcpeak For This Useful Post:
Ashu2912 (July 28th, 2011)