In: Computer Science
<!DOCTYPE html>
<html>
<head>
<title>Image Swap Application</title>
<link rel="stylesheet" type="text/css" href="image_swap.css">
<script type="text/javascript" src="image_swap.js"></script>
</head>
<body>
<main>
<h1>Fishing Images</h1>
<p>Click on an image to enlarge.</p>
<ul id="imageLinks">
<li><a href="images/release.jpg" title="Catch and Release">
<img src="thumbnails/release.jpg" alt=""></a></li>
<li><a href="images/deer.jpg" title="Deer at Play">
<img src="thumbnails/deer.jpg" alt=""></a></li>
<li><a href="images/hero.jpg" title="The Big One!">
<img src="thumbnails/hero.jpg" alt=""></a></li>
<li><a href="images/bison.jpg" title="Grazing Bison">
<img src="thumbnails/bison.jpg" alt=""></a></li>
</ul>
<h2 id="caption">Catch and Release</h2>
<p><img id="main_image" src="images/release.jpg" alt=""></p>
</main>
</body>
</html>
Hi.
Document object model or DOM is a structure which specifies the tags, nested tags and their children. It also structures the text inside the objects. DOM tree is very useful to keep the records of the tags and their children.
In the above question, for the given html code:
<!DOCTYPE html>
<html>
<head>
<title>Image Swap Application</title>
<link rel="stylesheet" type="text/css" href="image_swap.css">
<script type="text/javascript" src="image_swap.js"></script>
</head>
<body>
<main>
<h1>Fishing Images</h1>
<p>Click on an image to enlarge.</p>
<ul id="imageLinks">
<li><a href="images/release.jpg" title="Catch and Release">
<img src="thumbnails/release.jpg" ></a></li>
<li><a href="images/deer.jpg" title="Deer at Play">
<img src="thumbnails/deer.jpg" ></a></li>
<li><a href="images/hero.jpg" title="The Big One!">
<img src="thumbnails/hero.jpg" ></a></li>
<li><a href="images/bison.jpg" title="Grazing Bison">
<img src="thumbnails/bison.jpg" ></a></li>
</ul>
<h2 id="caption">Catch and Release</h2>
<p><img id="main_image" src="images/release.jpg" ></p>
</main>
</body>
</html>
The DOM tree will be:
And the output of the html file will be:
For any doubts please comment below.