Wrap link around

后端 未结 8 1042
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 06:54

Is it possible to wrap an tag around

8条回答
  •  情深已故
    2020-11-28 07:24

    HTML provides two general elements, where div is a natural block element, and span is a natural inline element. All other elements are similarly assigned to be a natural block or inline.

    Now, while both can be made by css display to be any of inline, inline-block or block, they are still treated for enclosure purposes as their natural selves, hence the warning messages. Leopards and spots sort of thing.

    However, css is only meant to be for making what an element looks like (presentation), but not actually be like (functionality), so it doesn't change an element's basic nature, though that gets very fuzzy in practice. A span made block becomes a bully that kicks everything else off the line, which is very un-inline sort of behaviour.

    So, to mitigate against possible conflicts between their natural and css-induced behaviours, it is better to allow:

    • div or any natural block tag to only ever be block or inline-block.
    • span or any natural inline tag to only ever be inline or inline-block.

    This will also mitigate against tending to build page structures that will likely end up churning out error and warning messages.

    Basically, NEVER embed a natural block tag inside a natural inline tag, at any depth.

    Why there is a really a distinction is perhaps due to a simplistic idea of what HTML was going to be used for when it was first dreamed up.

    Certainly, framework makers got around a lot of these what-to-embed-where problems by just using myriads of divs everywhere, and 'divitis' was born, and still alive and well in every framework. Just have to press F12 in a browser on almost any commercial web page and drill down through a dozen divs. This very page has 15 unbroken levels of divs.

    It meant that they really only had to manage one tag per purpose and manage it as if it was an isolated environment. So what was meant to be an occasionally-used functional grouping tag became the web's Lego block. And none of them are going to risk breaking their frameworks by converting to HTML5 semantic tags in a hurry.

提交回复
热议问题