<div>s have a block display model.
<span>s have an inline display model.
Is there any element without any presentation purpose, whose unique goal would be to group other elements ?
preguntado el 22 de mayo de 12 a las 15:05
No. Every element must have a value for the
display property. CSS doesn't allow for the possibility of a null value.
<span> are the generic grouping elements, and there are numerous non-generic grouping elements. You just have to select the right one for the context (which depends on the markup and semantics involved, not the default value of
Well - at least with CSS3 you can control it better, e.g. in your div
This can be used to the same effect as a reset style sheet.
span has no semantic meaning; they are made exactly for the purpose of grouping elements.
No, there are no elements used for grouping any kind of visual elements.
Puede utilizar el
<tbody> elements to group
<tr> elements in a table.
<span> elements as well as newer semantic elements such as
<section> etc. fulfill the purpose of grouping, they all come with default user agent styles.
Though it is possible to override these styles as needed, the nesting of elements within the DOM tree itself may have undesired effects. For instance, when using
display: flex; on a parent element, the rendering of its immediate child elements (
>) is influenced by this.
The new CSS
display: contents; property value is intended to solve this issue:
display: contents causes an element's children to appear as if they were direct children of the element's parent, ignoring the element itself. This can be useful when a wrapper element should be ignored when using CSS grid or similar layout techniques.
Yet, the browser support is not as good as one would hope by the end of 2020:
Further details on how the implementation debemos work in detail can be found in the spec: