Forum Moderators: mack
I have a page which has the follwoing piece of javascript in it to handle expanding and collapsing a unordered list that i am going to use as a menu however when I validate the code it states that 'document type does not allow element "img" here'
Here is the relevant bits of code minus the javascript:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text-html; charset=utf-8" />
<title>Expanding Menu</title>
</head>
<body>
<ul>
<li>
<script type="javascript">document.writeln('<img id="bar1" src="closed.png" alt="Open list" onclick="toggle(\'bar1\',\'section1\');" />');></script>
<a href="javascript:toggle('bar1','section1')">Section 1</a>
</li>
</ul>
<ul id="section1">
<li><a href="page1.html">Item 1</a></li>
<li><a href="#">Item 2</a> </li>
<li><a href="#">Item 3</a> </li>
<li><a href="#">Item 4</a> </li>
</ul>
</body>
</html>
The error relates to the line:
<script type="javascript">document.writeln('<img id="bar1" src="closed.png" alt="Open list" onclick="toggle(\'bar1\',\'section1\');" />');></script>
Why can I not put an img tag there?
Any help appreciated