Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

whats the difference between the <u> tag and the <ins> tag?

Tags:

html

what's the difference between these two tags? seems to do the same thing.

<p>My favorite color is  <ins>red</ins>!</p>


and

<p>My favorite color is  <u>red</u>!</p>
like image 707
Elye M. Avatar asked Aug 27 '12 19:08

Elye M.


2 Answers

Semantics. The <ins> tags means content inserted after it was first published. The <u> tag is simply for underlining and has no meaning.

Reference: <ins>, <u>

like image 72
j08691 Avatar answered Oct 20 '22 14:10

j08691


The official difference depends on the HTML specification or draft that you choose to regard as official.

By the HTML 4.01 specification, u means underlined text style, whereas ins means that its content has been “inserted [...] with respect to a different version of a document (e.g., in draft legislation where lawmakers need to view the changes). The rendering of ins is not specified; instead, some possible renderings are described. In practice, browsers mostly use underlining. There is also the formal syntactic difference that u allows text-level content only, whereas ins may contain blocks, too.

In the HTML5 drafts, ins is essentially similar but with different wordings and with an explicit suggestion, or maybe (semi)recommendation, that the default rendering use underlining (see 10.3.4 Phrasing content there). The u was previously excluded from the draft, now added but with invented meaning: “The u element represents a span of text with an unarticulated, though explicitly rendered, non-textual annotation, such as labeling the text as being a proper name in Chinese text (a Chinese proper name mark), or labeling the text as being misspelt.” If this does not make sense to you, you’re not the only one. And u has underlining as the suggested, or recommended, default rendering.

In practice, the effect is mostly the same, except that ins tags are ignored by some old browsers. Some exotic browser could use different rendering. I have not seen any evidence of any browser, search engine, or any other relevant software make any distinction between the two; their “semantic difference” has no practical impact.

However, I would not use ins for anything except inserted text in some sense, just because some future browsers might treat it in some way that makes sense for inserted text but not otherwise. And there would be no tangible benefit from using ins just for underlining: u is shorter markup and more widely supported. Then again, situations where you should underline text, except links, on web pages are rare.

like image 30
Jukka K. Korpela Avatar answered Oct 20 '22 16:10

Jukka K. Korpela