View Full Version : XHTML validation problem
Anarchist
03-16-2005, 12:12 AM
I am trying to get my code to validate as XHTML but one line is preventing me from doing so.This is the line:
<p align="left"><legend>Are you a current student?</legend>
How can I still use a legend and be valid?
Hi,
This actually belongs in the HTML & CSS forum I believe... ;)
The "legend" tag is valid - you can use it in xhtml markup if used correctly with a fieldset.
http://www.w3schools.com/tags/tag_legend.asp
Are you sure that the error is not coming from the unclosed <p> tag?
You may want to post a bit more code and a link to the page in question so that the guys here can fully understand the situation and help. The validator should have both pointed out the "exact" error and even suggested a solution... did you use the validator at w3.org?
Daf
Anarchist
03-16-2005, 12:38 AM
Thanks, I thought the post belonged here as I am working on a XHTML page and am trying to validate it as such...I used the validator you pointed out yes. If this piece of code aint enough I can post a link to the file [no problem]
<div align="left">
<fieldset>
<p><legend>Are you a current student?</legend><br />
<input type="radio" name="cur_student" value="grad" id="grad" tabindex="13" /> <label for="grad">Current Graduate Student</label><br />
<input type="radio" name="cur_student" value="ugrad" id="ugrad" /> <label for="ugrad">Current Undergraduate Student</label><br />
<input name="cur_student" type="radio" value="none" checked="checked" id="none" tabindex="15" /> <label for="none">None: not a current student</label><br /></p>
</fieldset>
</div>
Error:
The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
It appears that the legend tags are not permitted within the paragraph tags.
If you remove the paragraph tags it will validate. If you are wanting the indenting and margins of a paragraph you might try adding the appropriate padding to the container div.
That should get you "valid".
Also - XML and XHTML are a 2 different animals. ;)
Daf
Anarchist
03-16-2005, 01:44 AM
I'll try that, I just followed the sign on the door.
Talk about XML and related technologies such as XSL, XHTML here.
mindlessLemming
03-16-2005, 06:21 AM
Also, remove the <br /> after <legend> -- it's not needed.
If you want the form elements further away from the top of the form, use
fieldset { padding-top:20px; } in your css
:)
Dodge
03-16-2005, 11:52 AM
I'll try that, I just followed the sign on the door.
Talk about XML and related technologies such as XSL, XHTML here.
Doh!! Sorry about that I didn't see that there...
Somewhat unexpected, for me, to see it listed there.
Daf
Anarchist
03-16-2005, 11:57 AM
No problem mate, thanks for the input
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.