Hey guys, I’m new to Javascript and I have a few simple problems that I can’t figure out. The problems require me to copy from the textbook and run it through the validator on w3, then correct the errors. However, I keep getting problems that I have no idea how to solve. I look through the chapter in my book, but I can’t come up with anything. For the first problem, I’m getting error messages like:
Error Line 20, Column 20: document type does not allow element “ul” here
document.write(“<ul>”);
(the > is underlined and in red, as well as the ” in another message)
Line 21, Column 38: character data is not allowed here
document.write(“<li>Eat less fat</li>”)
(the last ” is underlined and red)
I know these are probably very simple problems for you guys, but I’m stuck and have no idea on how to correct them. Any help is appreciated.
[CODE]
<!DOCTYPE html PUBLIC
“-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Dietary Recommendations</title>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1″ />
</head>
<body>
<h1>Dietary Recommendations</h1>
<p>The American Heart Association recommends the following dietary guidelines for a healthy heart:</p>
<script type=”text/javascript”>
/* <![CDATA[ */
/*
Joshua Meadors
10/24/2012
Exercise 1-6
*/
/* ]]> */
document.write(“<ul>”);
document.write(“<li>Eat less fat</li>”)
document.write(“<li>Avoid sugary and processed foods</li>”)
document.write(“<li>Eat plenty of fiber-rich foods</li>”)
document.write(“<li>Cut down on salt</li>”)
document.write(“<li>Eat at least 400g of fruit and vegetables each day</li>”)
document.write(“<ul>”);
</script>
</body>
</html>