Can block elements be placed inside lowercase?

<span><div></div><div></div></span> 

Is this code correct?

  • one
    The only question is: why? I remember the parable of the trolley from a loaf of bread - SLy_huh

3 answers 3

No, it is not valid, it is better to write the opposite

 <div><span></span><span></span></div> 
  • 3
    <div style="display: inline"><div></div></div> right? and <span style="dislplay: block"><div></div></span> ? - Sergey
  • 1 option, but better use css styles. Inside the span do not need to use a div - zrishat
  • one
    Unclear some rule is obtained. It would be logical to assume that the line element can be contained in a block element, but not vice versa. But if the block element is usually replaced with a lowercase style and it remains correct, then why not immediately place it in the initially lowercase element? - Sergey
  • span tag is designed for the design of the text, it is not a block, as a div - zrishat
  • It is possible to invest, but then it is hard to achieve cross-browser compatibility. Editors swear warning warnings for such an attachment. - nick_n_a

According to the WHATWG phrasing content can be inserted inside the span element.

Source: Semantics of span element , phrasing content

If you omit the semantics, you can embed anything inside the span, the main thing is to make sure that it is block, that is, it can be added to it in display: block styles.

    1. No, such an attachment is not valid.
    2. All browsers will handle it correctly and there will be no problems.
    3. It is worth taking care of the correct values ​​of the display property.