1

I am working on a website where users can post comments. I intend to use the <ins>-element herefore. When comments are inaccurate, they will be marked as deleted using the <del>-element.

My first question is whether I use the semantics of these elements correctly?

It surprised me when I saw at W3C that these two elements can contain block-level-elements inside it since that is usually not the case for text-elements who are set to display: inline; (cannot have a width, height etc.). I checked the computed browser value which is definately display: inline; for both <del> and <ins>.

So my second question is how the browser makes this special behavior to work? (Or is it even special? - am I missing something?)

Ape
  • 58
  • 7

1 Answers1

1

Try not to confuse styling (CSS) with the HTML content model. These are deliberately separate and orthogonal concepts. The only link is that some HTML elements have a consistent default styling.

Although ins and del could be used the way you describe in HTML4, HTML5 makes this separation much more distinct, because it does not use the terms "block" and "inline". These terms are left to CSS. HTML5's content model uses separate categorization, including "flow", "phrasing", and important in this case, "transparent"

The content model is used to assist a document content's meaning. But browsers do not care about the meaning, only how to render it.

CSS provides clear rules about how to render block elements inside inline elements, completely regardless of HTML's content model restrictions. See this answer: Is it wrong to change a block element to inline with CSS if it contains another block element? .

So, no the behaviour isn't "special", and browsers do not have to do anything except use the normal CSS rules to handle it.

As for your first question, it's hard to tell whether "inaccuracy" should imply use of <del>. If the commenter intends to withdraw that inaccuracy, then <del> would be appropriate, otherwise probably not.

Community
  • 1
  • 1
Alohci
  • 78,296
  • 16
  • 112
  • 156