Forum Moderators: open
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
example.net
</title>
<script language="javascript" type="text/javascript" src="MyScript.js" />
</head>
<body>
<form name="form1" method="post" action="default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJ" />
</div>
<div>
<table>
<tr>
<td style="width: 100px">
<img alt="" src="pictures/logo.JPG" /></td>
<td style="width: 100px">
</td>
</tr>
</table>
</div>
<div style="width: 209px; height: 18px">
</div>
</form>
</body>
</html>
-------------------------------------------------------------------
please give me advice. thanks
[edited by: encyclo at 2:24 am (utc) on Nov. 30, 2006]
[edit reason] removed specifics and unnecessary code [/edit]
There is an end tag by definition, which is always required. The <script> tag is not like the <img>, <br> or <meta> tags etc. which do not have a closing tag in HTML, because the <script> tag can itself have content if the SRC attribute is not used. ie.
<script type="text/javascript">
window.onload = myFunc;
function myFunc() {
alert('Page has loaded!');
}
</script>
i open my page on Firefox, it display correct. When i open it with IE it doesn't display enything ... validator.w3.org, the result is: passed validation.
Hhhmmm, OK (soz, kinda danced over that last bit on first read)... so who is correct here?! Should you be able to use the minimized closing tag with the <script> element in XHTML ...? Or has the Validator been fooled in this instance? Or is it simply that browser (IE) support is not what it should be?
Should you be able to use the minimized closing tag with the <script> element in XHTML ...?
The validator is entirely correct in a technical sense (XHTML is XML so you can close empty elements with a slash), but in the real world the browser support (I mean IE) is sketchy at best.
Run this through the validator, for example:
<!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" xml:lang="en" lang="en">
<head><title>test</title></head><body>
<div />
<ol>
<li>text</li>
<li />
</ol>
<p>text</p>
</body>
</html> Firefox handles this kind of markup better when serving the file correctly as
application/xhtml+xml (with the XML parser), but even when served as text/html you should see the empty second list item. In IE, this approach is a recipe for disaster... but as we know, IE doesn't support XHTML so it can't be expected to handle markup written in this way. So who now still thinks that XHTML is backwards-compatible with HTML? ;)