* What you should depends on the context and purpose, like what you
   are using <label> for, why it should contain a paragraph, and how do
   you wish to style things.


I didn't understand your last paragraph ?

Placing a <p> tag within a <label> causes the browser to ignore the <label> tag, that is the information I strictly understood, as it was direct !



Jukka K. Korpela wrote:
2014-07-09 20:58, Crest Christopher wrote:

I've had to restyle my form and it has caused the validator to inform me
I'm not allowed to use <p> as a child element of a <label> tag ?

The information is correct, see e.g.
http://www.w3.org/TR/REC-html40/interact/forms.html#edef-LABEL
http://www.w3.org/TR/html5/forms.html#the-label-element
Only "inline content" / "phrasing content" is allowed, e.g. <span> is OK, <p> is not. This is natural, since the element is supposed to contain a short label (caption) for a control, like "Name" or "Address" or something a bit longer, but not a paragraph.

What matters in CSS here is that the syntax rule is not just a formal rule. Browsers actually enforce it in parsing, and this affects what happens when you style a <label> element. Consider this example:

<!doctype html>
<title> </title>
<style>
label { outline: solid red }
</style>
<label>foo <p>bar</p> done</label>

This is invalid markup, but what matters in practice is that in browsers, the <p> tag closes the open <label> element (and the closing tag </label> later will be ignored). So the CSS rule will draw an outline around the word "foo" only.

What you should depends on the context and purpose, like what you are using <label> for, why it should contain a paragraph, and how do you wish to style things.

Yucca


______________________________________________________________________
css-discuss [css-d@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
______________________________________________________________________
css-discuss [css-d@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to