gpt4 book ai didi

html - 什么时候最好使用 HTML 表示标签或 CSS 来设计元素?

转载 作者:行者123 更新时间:2023-12-03 23:11:34 26 4
gpt4 key购买 nike

关闭。这个问题是opinion-based .它目前不接受答案。












想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题.

去年关闭。




Improve this question




通过在 HTML 和 CSS 中使用 class="pro"来使用这种方法有什么区别。

<p>a <u>pro</u>grammar</p> 
在 HTML 中?
HTML 使用类...
<p>a <span class="pro">pro</span>programmer.</p>
CSS类
.pro {text-decoration: underline;}
结果是一样的,但我想知道是否有理由为什么我应该使用一个而不是另一个。

最佳答案

<u>标签

The HTML Unarticulated Annotation element (<u>) represents a span of inline text which should be rendered in a way that indicates that it has a non-textual annotation. This is rendered by default as a simple solid underline, but may be altered using CSS.


避免使用 <u>
非语义下划线

To underline text without implying any semantic meaning, use a <span> element with the text-decoration property set to "underline".


注意:

Along with other pure styling elements, the original HTML Underline () element was deprecated in HTML 4; however, <u> was restored in HTML 5 with a new, semantic, meaning: to mark text as having some form of non-textual annotation applied.


重要提示:-

Be careful to avoid using the <u> element with its default styling (of underlined text) in such a way as to be confused with a hyperlink, which is also underlined by default.

<span>标签

The HTML <span> element is a generic inline container for phrasing content, which does not inherently represent anything.



.pro {text-decoration: underline;}
<p>a <u>pro</u>grammar</p> 
<p>a <span class="pro">pro</span>programmer.</p>

关于html - 什么时候最好使用 HTML 表示标签或 CSS 来设计元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64021034/

26 4 0