In today’s web development it is common to build reusable components (the exact technology matters little) that may accept arbitrary children or parents. This means that the element used to implement this component needs to be as neutral as possible. For this,
span is typically preferred. It would be possible to use
div but it has downsides, notably its default block styling and the fact that it will close
p if the tree is serialised to HTML.
The only downside to
span is that it is considered an error as per Restrictions on content models and on attribute values. While it works perfectly well, developers are then dismayed to find out that the validator disagrees with them. Here is the example that prompted this post but it is not at all the only one, I’ve seen this complaint crop up several times over the past month. It’s a shame to get developers to fix something that’s not a problem.
This rule is meant “to avoid misuse of elements with defined meanings” but
span “doesn’t mean anything on its own” and simply represents its children.
I would therefore suggest changing
span's content model to take flow content instead of phrasing content.