Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does legend do accept block elements?

Tags:

html

I have this layout where, semantically, the legend of a complex fieldset, has a little description.

It seems that the legend just accepts: Phrasing content (btw, is the the same as inline elements?). http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#flow-content-3

Or more officially: w3.org/TR/html5/rendering.html#flow-content-0

Would it be acceptable to change the display property of a legend to Block; ?

Or is it preferable to do it differently?

I mean, could I have some drawbacks (that I'm not seeing at the moment) for changing a legend to block, and allow some <p> and <div> and <aside> inside it?

like image 882
MEM Avatar asked Jun 26 '26 05:06

MEM


1 Answers

Would it be acceptable to change the display property of a legend to Block; ?

Of course it would be, but -

I mean, could I have some drawbacks (that I'm not seeing at the moment) for changing a legend to block, and allow some <p> and <div> and <aside> inside it?

- that would still not make this valid HTML.

Formatting an element via CSS does not change anything about what content is allowed for that element structurally in HTML.

So the answer is No - you can not put p, div or aside elements into a legend if you want valid HTML, no matter how you format it with CSS.

The spec is quite clear about what constitutes phrasing content - and that's what you can put inside a legend, and not anything else that is not categorized as phrasing content.

[from comments] As I said. It's a very complex legend. :) Ie. "On this next boxes, you have several choices. According to your level, you may choose the one who best fits your interests. Please have a look at the following table to help you out..."

That should not be a legend IMHO.

Think of a legend more like a headline of some sort.

Additional text that explains what choices the user has etc., should follow the legend - and then use can use div, p etc. because the content model of fieldset is flow content.

like image 95
CBroe Avatar answered Jun 27 '26 18:06

CBroe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!