1

I know that <label> elements must not include native block elements as <div> and so on. Inline Elements are allowed as <span>, so is the following okay too?

<label>
<span style="display: block"></span>
</label>

The W3C Validator don't show up any info or error about this.

EDIT - i made some examples and they're working fine in chrome, firefox und opera. IE seems to have issues with the flexbox attributes at all and i'm not able to test on safari because of lack of apples in my house. But the block displayed <span> element seems to work fine without any issues.

https://jsfiddle.net/76ak2fhz/

Flo
  • 137
  • 3
  • 20
  • What are you trying to do? – Srax Dec 04 '17 at 22:54
  • i want to make some individual styled inputs (radio and checkbox). I know there are few different on the web but with them some problems occure, like absolute positioned span elements. – Flo Dec 04 '17 at 22:57
  • Check this https://www.w3schools.com/tags/tag_label.asp – Srax Dec 04 '17 at 22:58
  • @Srax i can't find any information about my question at this side. – Flo Dec 04 '17 at 23:01
  • 1
    @showdev okay, but thats all about including block and inline elements. If i want just to put some css rules like width and height on the block-displayed spans? – Flo Dec 04 '17 at 23:16
  • You're right. Sorry, I can't reliably claim to know the answer. ¯\\_(ツ)_/¯ The consensus *seems* to be that [CSS is irrelevant](https://stackoverflow.com/questions/1142104/difference-between-div-as-is-and-a-span-with-displayblock) to the HTML DTD. So it seems to me that your code would be valid; a ` – showdev Dec 04 '17 at 23:42
  • @showdev it seems to work fine - i added a fiddle on my post. – Flo Dec 07 '17 at 19:56
  • Cool, that looks nice. Great work. – showdev Dec 07 '17 at 21:16

0 Answers0