Why is my document not validated as XHTML 1.1 STRICT?

While target = "_ blank" is deprecated, why doesn't the W3C validator give an error about this? You can paste and check this code in 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 this mean that XHTML 1.1 supports target = "_ blank", but XHTML 1.0 strict does not work? Or is this a bug in the W3C validator?

+5
w3c xhtml doctype xml-attribute
source share
6 answers

You are verified as XHTML Transient , not Strict . If you manually override doctype to XHTML 1.0 Strict, you will get this error:

Error line 11, column 76: The "target" attribute exists, but cannot be used for this element.

... om "title =" A new window opens "target =" _ blank "> The link opens in a 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"> 

Transitional schemes still allow certain obsolete elements and attributes, I think, to help people move with a step to more stringent markup.

EDIT:

OK, so the source code was XHTML 1.1, in which there is only one version (no Strict / Transitional), and according to this FAQ, the target attribute is really not allowed. Therefore, I assume that this should be a mistake in the validator.

+4
source share

It is outdated but not deleted. That is why I think there is a problem in confirming this.

+2
source share

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

+2
source share

Does this mean that XHTML 1.1 supports target = "_ blank", but XHTML 1.0 is strictly 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".

+2
source share

I used your code and I got the following error.

Error checking this document as XHTML 1.1!

Test Result: 1 Error

  • Error line 11, column 76: no "target" attribute

    .... com "title =" A new window opens "target =" _ blank "> The link opens in a new window

The validator is operating as of January 30, 2012. You cannot pass the test with target = "_ blank"

Replace this valid piece of code:

OnClick = "target = '_ empty';"

+1
source share

While xhtml may support "targrt =" _ blank ", it DOES NOT check it because it has been depreciated. If you do not want to use JS, you will have to use a transient rather than strict in your" document type ",.

0
source share

All Articles