broken URI fragments (such as index.html#fragment)

Justin Hileman justin at justinhileman.info
Thu Apr 2 20:44:32 MDT 2009


Charles Curley wrote:
> While running the W3 Consortium's link checker
> (http://validator.w3.org/checklink?check=Check&hide_type=all&summary=on&uri=http%3A%2F%2Fwww.charlescurley.com%2Findex.html),
> I get messages like:
>
> Lines: 403, 405, 407, 409, 411, 413, 637 http://www.charlescurley.com/frames.article.html
>      Status: 200 OK
>
>      Some of the links to this resource point to broken URI fragments (such as index.html#fragment).
>      Broken fragments:
>
>          * http://www.charlescurley.com/frames.article.html#TOC128 (line 409)
>          * http://www.charlescurley.com/frames.article.html#TOC130 (line 413)
>          * http://www.charlescurley.com/frames.article.html#TOC126 (line 405)
>          ....
>
> What do they mean by broken fragments?
>
> The anchors are there, e.g.:
>
> <h2><a name="TOC130">Acknowledgments</a></h2>
>
> and the links to them look like:
>
>      <li><a href="frames.article.html#TOC130">Acknowledgments</a>
>
> Should I change anything?


RFC2396 (URI generic syntax) says that fragments refer to ID type 
attributes. In HTML 4 and XHTML, this is the "id" attribute, not "name". 
I.E. you don't actually have a target for that link, because there's no 
anchor with that id. For backwards compatibility you can still browse to 
an anchor via "name", but it's not XHTML strict. Since your page 
declares a XHTML strict doctype, I imagine the validator is explicitly 
looking for the id.

It will still work with "name", and will prob'ly always work that way. 
If you want to validate links and/or make things future proof, you 
should add an id to your anchors, e.g:

<h2><a id="TOC130" name="TOC130">Acknowledgments</a></h2>

See the XHTML 1.0 compatibility guidelines:

http://www.w3.org/TR/xhtml1/guidelines.html#C_8


-- 
justin
http://justinhileman.com




More information about the PLUG mailing list