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

6

5

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?

Mcculloch answered 16/12, 2009 at 11:39 Comment(0)
E
4

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.

Ermina answered 16/12, 2009 at 11:46 Comment(1)
Is it really a bug in w3c validatorMcculloch
C
2

It is deprecated but not removed. That's why i think there is problem in validating that.

Chophouse answered 16/12, 2009 at 11:48 Comment(0)
P
2

The XHTML1.1 documentation shows that the target attribute of an a element can be "anything".

Pommel answered 16/12, 2009 at 11:54 Comment(1)
it means XHTML 1.1 support target=”_blank”?Mcculloch
C
2

Does it means XHTML 1.1 support target=”_blank” but XHTML 1.0 strict not?

Well, Yes.

If you need a workaround for your problem, then this is one of them. Another option is to use window.open() instead of target="_blank".

Catfall answered 16/12, 2009 at 12:10 Comment(1)
but if i'm working with XHTML 1.1 then can i use target=”_blank”?Mcculloch
W
1

I used your code and I got the following error.

Error found while checking this document as XHTML 1.1!

Validation Output: 1 Error

  1. Error Line 11, Column 76: there is no attribute "target"

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

The validator is working as of 1/30/2012. You cannot pass validation using target="_blank"

Replace with this valid portion of code:

onclick="target='_blank';"

Wearisome answered 30/1, 2012 at 6:46 Comment(0)
P
0

While xhtml may support "targrt="_blank", it WILL NOT validate it because it hase been depreciated. If you don't want to use JS, you will have to use transitional instead of strict in your "document type".

Phionna answered 19/4, 2010 at 21:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.