|
| |
|
|
Starhugger
Posts: 494 Joined: 4/12/2005 Status: offline
|
Titles in named anchors - 3/28/2008 15:59:33
I'm doing a job right now of cleaning up some very nasty code created by a CMS editor (not one of the well known ones). It seems to default to including a TITLE attribute in its named anchor tags; for example: <a name="blahblahblah"> This doesn't quite make sense to me since it's not a link, as such; it's a named location that a link would point to. ...Unless there's some advantage in doing this for accessibility reasons. Does anyone know of anything like this? Can you think of any reason a named anchor would require or have any use for a title attribute? Or is this like a fish to a bicycle? Thanks! Starhugger
|
|
|
|
Tailslide
Posts: 5915 Joined: 5/10/2005 From: Out here on the raggedy edge Status: offline
|
RE: Titles in named anchors - 3/29/2008 3:38:44
So what you're saying is that it's adding a title attribute like this:
<a name="blahblahblah" title="blah blah blah" href="whatever.html"> Using a title attribute as above is useful if it's providing extra information about the link. 99% of the time it's better if you can just make the link text actually informative - then you don't need the title attribute. Title attributes aren't read by default by screenreaders but they can be set up to. Problem is that most people just use them to repeat the information contained in the link text which is pointless really. If you mean that it's adding a title attribute to an anchor tag (e.g. used for internal page linking) then far as I can see it's completely pointless. It would be useful however to add an id and then you can phase out the need for the name attribute as that's only needed for very old browsers now ( unless it's required for some old-style JS stuff)
_____________________________
"My strategy is so simple an idiot could have devised it" Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project
|
|
|
|
Starhugger
Posts: 494 Joined: 4/12/2005 Status: offline
|
RE: Titles in named anchors - 3/29/2008 17:30:20
In this case, it's just an internal anchor tag. If it was a link, I could at least see its purpose, even if there are more efficient ways to serve the same purpose. I'm assuming it was the CMS system that created this stuff. I just wasn't sure if there was some accessibility advantage in it somehow. It's the only rational explanation I could think of, other than it just being dirty code. Sounds like it's just the latter. How does the ID work in a named anchor tag? Does it replace the name (e.g. < a id = "blahblah" > ) or is it in addition to the name? (e.g. < a id = "blahblah" name = "blahblahblah" > ) If in addition to, what is the advantage of using both? Thanks Tail! SH
|
|
|
|
Tailslide
Posts: 5915 Joined: 5/10/2005 From: Out here on the raggedy edge Status: offline
|
RE: Titles in named anchors - 3/31/2008 3:42:26
In XHTML "Name" has been deprecated in favour of ID in pretty much all tags except links and form inputs where you can use either or both. In HTML, far as I remember either is fine. Which you use is dependent on what type of HTML you use and what you use the ID and Name for - for instance, you might be using an older style bit of Javascript which needs the "Name" of a tag to work properly (this happens a lot with forms). If you're using CSS then you may want an ID in there too to give you styling options. If you're using some modern bit of DOM scripting javascript then that works using the ID not the name so you don't need name at all!! Personally - I favour the belt and braces technique here. In anchor links I use both ID and Name - reason being that older IE versions (pre-IE6) need the name to work properly. In forms I tend to also have both ID and Name in form inputs just in case I add in a bit of scripting that needs it. It does no harm. I don't use "Name" anywhere else.
_____________________________
"My strategy is so simple an idiot could have devised it" Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|