Welcome to Atlanta .NET Regular Guys Sign in | Join | Help

Nested anchor links cause trouble

I was working on an web application today that was having trouble rendering correct.  The client added a link to the page and color of the text after that link would render incorrectly.  If they took the <a href></a> anchor tag out of the HTML it would render fine.  So I looked at the HTML for them and found that they had the anchor tags inside of a list and that one of the lists had not been closed properly. I thought that might be it, but No luck.  I then noticed that they were using the anchor tag like a div tag.

<a class="content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer nonummy tincidunt turpis. Cras venenatis. Vestibulum vehicula. Pellentesque quam enim, porttitor at, ultrices et, semper eget, odio. Integer quis libero. <a href="link.htm">Link Text</a>Aliquam erat justo, lobortis at, laoreet vel, commodo ac, nisl. Etiam ullamcorper viverra velit. Etiam non nibh. Etiam ut urna nec neque mollis adipiscing. Vestibulum id libero. Curabitur ornare nulla eget felis.
</a>

The problem, as you may or may not know, is that you cannot have nested anchor links.
Check it out: http://www.w3.org/TR/html4/struct/links.html#h-12.2.2

 The simple fix here is to change the outside anchor tags that are used like containers to div tags.

Here are both examples on one page
http://devcow.com/blogs/adnrg/samples/nestedanchor.htm

Published 14-11-2006 07:12 by Brendon Schwartz
Filed Under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Dan Attis said:

Why on earth would someone think they needed nested anchor tags?  The very thought of it makes no sense.  That is a weird one.
November 15, 2006 5:08 AM
 

Steven Vore said:

I'm right there with Dan - my first thought was "Why?" Did they explain what their rationale was for doing that?
November 15, 2006 9:18 AM
 

Brendon Schwartz said:

The code was not written in house, so I have not idea what they were thinking.  It appears they thought that the anchor tag without an ID or href would work like a div.  No other info besides that, sorry.
November 15, 2006 9:42 AM
 

Chris Wallace said:

Going off the comments and my own thoughts, this one belongs on the daily wtf.
November 22, 2006 7:40 AM
 

richard said:

ghnook dkv7Rq29nVvzm74lApqSw
May 12, 2009 9:32 AM
 

Ghvkhfhy said:

Very interesting tale <a href=" http://www.maclife.com/user/drandrew ">utah lds rape</a>  %DD <a href=" http://www.maclife.com/user/drethan ">ucsb adds american asian rape videos</a>  :-P <a href=" http://www.maclife.com/user/drdaniel ">rape child</a>  gpu
May 16, 2009 9:49 AM
 

Blszrncl said:

Excellent work, Nice Design <a href=" http://www.maclife.com/user/drjoseph ">lolita bondage rape</a>  03022 <a href=" http://www.maclife.com/user/drwilliam ">free stories inndian rape</a>  krfk <a href=" http://www.maclife.com/user/drchristopher ">Teen *** Gang Rape in College</a>  443426
May 16, 2009 1:05 PM
 

Yghaikvj said:

Best Site good looking <a href=" http://www.maclife.com/user/drsamuel ">rape hang comic</a>  60955 <a href=" http://www.maclife.com/user/drjonathan ">teen abortions among rape victims</a>  89116 <a href=" http://www.maclife.com/user/drchristian ">bias in duke lacrosse rape case</a>  7128
May 16, 2009 4:32 PM
 

Yghaikvj said:

Best Site good looking <a href=" http://www.maclife.com/user/drsamuel ">rape hang comic</a>  60955 <a href=" http://www.maclife.com/user/drjonathan ">teen abortions among rape victims</a>  89116 <a href=" http://www.maclife.com/user/drchristian ">bias in duke lacrosse rape case</a>  7128
May 16, 2009 4:33 PM
 

Gwqsekzn said:

Gloomy tales <a href=" http://www.maclife.com/user/drzachary ">soft rape</a>  mqhsv <a href=" http://www.maclife.com/user/drbenjamin ">anime rape vids</a>  ogpwl <a href=" http://www.maclife.com/user/drlogan ">cream and scream rape</a>  hspz
May 16, 2009 7:55 PM
 

Ncaobkuc said:

Cool site goodluck :) <a href=" http://www.maclife.com/user/drnoah ">link to http ybsearch com redir gang rape</a>  1368 <a href=" http://www.maclife.com/user/drjose ">rape video games</a>  02055 <a href=" http://www.maclife.com/user/drjustin ">lotr rape</a>  940
May 16, 2009 11:18 PM
 

Khhgmvhh said:

Wonderfull great site <a href=" http://www.maclife.com/user/drluke ">Arab rape movies</a>  >:( <a href=" http://www.maclife.com/user/drjack ">rohypnol the date rape drug womens health and medical information</a>  >:-OO <a href=" http://www.maclife.com/user/drjordan ">new york lawyer re-open statutory rape case</a>  xnm
May 17, 2009 2:56 AM
 

Mesqsbqx said:

magic story very thanks <a href=" http://www.maclife.com/user/drsean ">porn rape vidz</a>  8PP <a href=" http://www.maclife.com/user/drbryan ">hardcore rape trailers</a>  :-( <a href=" http://www.maclife.com/user/drowen ">teen gets anal rape</a>  truy
May 17, 2009 1:22 PM
 

Oqeauhcc said:

<a href=" http://www.maclife.com/user/drnathaniel ">rape galliers</a>  6996 <a href=" http://www.maclife.com/user/drlucas ">dark angel fanfiction rape</a>  472 <a href=" http://www.maclife.com/user/drian ">free hot rape clips clips</a>  %)))
May 17, 2009 4:38 PM
 

Hsxuudsp said:

It's funny goodluck <a href=" http://www.maclife.com/user/drseth ">young teen rape jpegs</a>  2316 <a href=" http://www.maclife.com/user/drdevin ">fantasy rape video</a>  baz <a href=" http://www.maclife.com/user/drjaden ">date rape stories</a>  470333
May 17, 2009 7:52 PM
 

Twcvncik said:

Gloomy tales <a href=" http://www.maclife.com/user/drcody ">rape fantasy porn</a>  uub <a href=" http://www.maclife.com/user/drcolin ">ear rape</a>  hiz <a href=" http://www.maclife.com/user/drcarter ">mythology of rape</a>  >:-(((
May 17, 2009 10:55 PM
 

Xxtelfkv said:

Cool site goodluck :) <a href=" http://www.maclife.com/user/drjoshua ">benitez mario rape suspect</a>  %))) <a href=" http://www.maclife.com/user/drmichael ">rape porn gang</a>  723604 <a href=" http://www.maclife.com/user/drmatthew ">statutory rape sentence in pa</a>  8-]]
May 18, 2009 5:27 AM

What do you think?

(required) 
(optional)
(required) 

About Brendon Schwartz

Brendon Schwartz has worked in the Atlanta area User Group scene and is known around town as one of the Atlanta .Net Regular Guys (www.devcow.com). He is currently on the INETA Board of Directors as the Vice President of Technology and is a Microsoft MVP for ASP.NET. Today, Brendon works to solve real world business problems with Microsoft technologies, such as SharePoint, Office, BizTalk, VSTS, and .NET technologies. In addition to presenting at local user groups, he helped create the Free Training 1,2,3! series (www.freetraining123.com) to help developers learn Microsoft technologies. He presented material at the first SharePoint 1,2,3! event (www.sharepoint123.com) along with other members of the Atlanta Microsoft Professionals. Brendon has helped on the leadership teams of five different user groups, and has been interviewed for his community efforts on Pod Casts - including the ASP.NET Pod Cast, .NET Rocks! (Carl Franklin Road Show - Atlanta) and the SharePoint Show Pod Cast. At the first Atlanta Code Camp in 2005, he presented material on ASP.NET mobile controls.
SkinName:iroha_Blog2
Powered by Community Server, by Telligent Systems