Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't my document validating as XHTML 1.1 STRICT?

While target="_blank" is deprecated, why is the W3C validator not giving an error about this ? You can paste and check this code int the validator:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<p>
<a href="http://www.stackoverflow.com" title="New window will open" target="_blank">Link opens in new window</a>
</p>
</body>
</html>

Edit:

Does it mean that XHTML 1.1 supports target=”_blank”, but XHTML 1.0 strict does not? Or is it a bug in the W3C validator?

like image 380
Jitendra Vyas Avatar asked Dec 16 '09 11:12

Jitendra Vyas


People also ask

Is xhtml strict?

There is no strict rules on structure when using HTML, but you should follow strict structure rules in XHTML. If you are using HTML, then you can use upper case and lower case for tags and attributes However, in XHTML, tags and attributes are strictly lower case.

What are xhtml standards?

XHTML documents are XML conforming. As such, they are readily viewed, edited, and validated with standard XML tools. XHTML documents can be written to operate as well or better than they did before in existing HTML 4-conforming user agents as well as in new, XHTML 1.0 conforming user agents.

Which doctype is common for xhtml?

The most commonly used and easy one is the XHTML Transitional document.


1 Answers

You are being validated as XHTML Transitional rather than Strict. If you manually override the doctype to XHTML 1.0 Strict you get this error:

Error Line 11, Column 76: Attribute "target" exists, but can not be used for this element.

…om" title="New window will open" target="_blank">Link opens in new window

Use this doctype if you want to be strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

The transitional schemas still allow certain deprecated elements and attributes, I guess to help people transition in steps towards a stricter markup.

EDIT:

OK, so the original code was XHTML 1.1 of which there is just one single version (no Strict/Transitional), and according this FAQ the target attribute is indeed not allowed. So I guess this must be a bug in the validator.

like image 175
Mike Weller Avatar answered Oct 17 '22 00:10

Mike Weller