View Full Version : Target attribute
Titties
08-22-2006, 10:57 AM
Hi
I have this problem that the target attibute doesnt seem to be Valid HTML 4.01 Strict!
my code line is like this:
<li><a href="http://www.konservativungdom.dk" target="_blank">Konservativ ungdom</a></li>
How do I fix the problem. I have many links, which should be opened in new windows...
Thx
Titoo
Use another DOCTYPE, ie. HTML 4.01 Transitional if you can't use XHTML.
blm126
08-22-2006, 12:21 PM
Use another DOCTYPE, ie. HTML 4.01 Transitional if you can't use XHTML.
Please don't suggest people use XHTML. It's just not a good thing (http://www.hixie.ch/advocacy/xhtml).
I know, I've read this document before, but many people still like XHTML so I suppose that they prefer it.
blm126
08-22-2006, 12:43 PM
Have you ever heard the phrase "jump on the bandwagon". Many people just learning HTML read something like "XHTML is the next best thing, why are you using HTML?" They then use XHTML because they have no information to base their decision on. If you don't believe me walk into a book store, go to the computer books section and see how many HTML books are there compared to XHTML. People new to HTML are never really given the chance to make an informed decision.
mwinter
08-22-2006, 12:50 PM
I know, I've read this document before, but many people still like XHTML so I suppose that they prefer it.
No, they're just misinformed. They think it's new and somehow better, when it's just as old as HTML (the XHTML 1.0 Recommendation was published only a few months after the HTML 4.01 Recommendation) and unsupported by the most used browser on the Web (MSIE).
Mike
And still, w3.org, w3schools.com, quirksmode.org, dynamicdrive.com and other web building related sites use XHTML. Even php's highlight_file/string function now produces XHTML valid output.
Titties
08-22-2006, 01:04 PM
thx guys, but please stay on-topic ;o)
mwinter
08-22-2006, 01:16 PM
And still, w3.org, w3schools.com, quirksmode.org, dynamicdrive.com and other web building related sites use XHTML. Even php's highlight_file/string function now produces XHTML valid output.
What makes you think any of that changes the facts? Most sites on the Web are invalid, but it doesn't make that a good idea, either. Anyone can fall victim to fads, however much they should know better.
thx guys, but please stay on-topic
This is a place for discussion, and discussions tend to wander. :)
Mike
Well one thing is that it's easier for the user-agent to show (parse) XHTML page (if it is a valid xhtml page) because it's done with XML parser (not all browsers do that though). And XHTML just looks nicer when all tags are lowercase and attributes quoted.
mwinter
08-22-2006, 01:45 PM
Well one thing is that it's easier for the user-agent to show (parse) XHTML page (if it is a valid xhtml page)
Validity doesn't make an XML document easier to parse: well-formedness does. Non-validating processors (the most common implementation) have to handle invalid documents.
because it's done with XML parser (not all browsers do that though).
However an XML processor will only be used if the document is served using an XML MIME type (text/xml, application/xml, or application/xhtml+xml). That is rarely ever done, and even if it is, it then becomes necessary to perform content negotiation so that other user agents (search engines, MSIE, and many other new and older browsers) can actually use the result. And therein lies another problem: many people try to perform the content negotiation themselves and completely screw it up (even though it might appear to work in limited tests).
And XHTML just looks nicer when all tags are lowercase and attributes quoted.
So does HTML. Since when has one been required to use uppercase? HTML is case-insensitive. Similarly, what's stopping an author from quoting all attributes? In fact, that's what I would recommend as most people don't know when attributes can be omitted (the rules are simple, but that doesn't stop authors from getting it wrong).
Mike
Well I don't mind if you use HTML. I don't force anyone to use or not to use XHTML, and I don't think that it's just bad or something. It's up to you how to write your web.
Titties
08-22-2006, 02:36 PM
This is a place for discussion, and discussions tend to wander. :)
Mike
It is fair, it's interesting to follow the discussion, but if you could try to help with the problem in question also, it would be really nice :D
Titties
Use HTML 4.01 Transitional, Strict doesn't allow the target attribute.
Titties
08-22-2006, 03:42 PM
But if I use Transitional, i get a bunch of other errors... the only problem is the target.
Isnt there som "onclick" commando to be used?
mwinter
08-22-2006, 04:13 PM
Well I don't mind if you use HTML.
And I don't really care if you use XHTML, however posting it may mislead others.
If someone understands, and is using XHTML, then if you post HTML they will be quite able to alter the markup. If they aren't, then they shouldn't be using XHTML in the first place. However, if the poster is unfamiliar with XHTML and is using HTML, they might not realise that they should change any XHTML markup you might suggest.
It is fair, it's interesting to follow the discussion, but if you could try to help with the problem in question also, it would be really nice
I didn't comment on your original question because I know you won't like my answer, but if you insist...
Don't open a new window at all. If you have links to external sites or whatever, by all means suggest that the user opens it in a new window (by shift-clicking, using the middle mouse button, the context menu, etc.), but don't force it on them.
Mike
Titties
08-22-2006, 04:57 PM
I didn't comment on your original question because I know you won't like my answer, but if you insist...
Don't open a new window at all. If you have links to external sites or whatever, by all means suggest that the user opens it in a new window (by shift-clicking, using the middle mouse button, the context menu, etc.), but don't force it on them.
Mike
Why swouldnt I like your answer? I appreciate any input i can possibly get. :) So please just say everything, as long as it is constructive criticism :D
Besides it isn't my choice to make, as I am making the site for a friend. But I'll try to pass on the message to him. It will ease my work, if I dont have to find a valid Strict method to open new windows in....
If you still want that onclick commando, you may use this:
<li><a href="http://www.konservativungdom.dk" onclick="window.open(this.href); return false;">Konservativ ungdom</a></li>
Titties
08-22-2006, 05:10 PM
Thank you - it works.
But as mike suggested, I'll still take it up for discussion whether the links should be opened in a new window or not.
Titoo
blm126
08-22-2006, 08:41 PM
I believe DimX's code is acceptable. It provides a backup for non-javascript enabled browsers. The best choice is to not do it, but if you must do that.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.