PDA

View Full Version : xhtml strict and the "top"


Dodge
07-26-2005, 05:29 PM
Hi all,

For years I used this:

<a id="top" name="top"></a> with an anchor to send folks back to the top of the page. Now that I am [trying] to recode xhtml strict this bit of code is causing the validator to cough... :\

I'm confused - how should I now use this method of defining/directing to the page top?

Thanks for any tips! :)

Dodge

Bill Posters
07-26-2005, 05:56 PM
You're nesting the anchor within a block level element, such as a div or p, right?

Other than that, there shouldn't be any problem getting that through the XHTML Strict validator.
If the nesting isn't the issue, what does the validator error actually state?

Dodge
07-26-2005, 06:31 PM
Hi,

Actually only by nesting within a block level did it validate... like so:

<p><a id="top" name="top"></a></p>



Using it "un-nested" threw the flags - here is the error from w3.org with it un -nested:

Line 16, column 22: document type does not allow element "a" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag

<a id="top" name="top"></a>

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").


Thanks
Dodge

Dodge
07-27-2005, 09:03 AM
No one knows? That really surprises me but... okay - thanks anyway.

Dodge

Bill Posters
07-27-2005, 09:24 AM
The question has already been answered by both myself and the validator error message.
You need to have the anchor (an 'inline' element) nested within a block element (such as those listed below) in order for the xhtml markup to validate.

"p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del"

Dodge
07-27-2005, 10:06 AM
I'm sorry, Bill, I misread/misunderstood you first response... I thought you were going a different direction - my bad.

Thanks for your replies - I do appreciate them. :)

Dodge

Bill Posters
07-27-2005, 10:21 AM
No worries. On second reading I can see how my first comment might have been taken to suggest that you shouldn't nest the anchor element, which of course, is the exact opposite of what I was actually getting at.

All's well that ends well …and all that malarkey. ;)