是否使用下划线?已弃用且未经验证?

发布于 2024-08-18 20:51:40 字数 25 浏览 4 评论 0原文

下划线的使用是否已被弃用且未经验证?

Is use of underline deprecated and non validated?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

纵山崖 2024-08-25 20:51:40

它在 HTML 4 http://www.w3 中已弃用。 org/TR/REC-html40/present/graphics.html#edef-U 因此不会验证。

请改用样式。也许是 标签。不过,如果您希望尝试添加下划线的内容在不启用样式的情况下得到强调。使用 标签并使用 CSS 为其添加下划线。

It's deprecated in HTML 4 http://www.w3.org/TR/REC-html40/present/graphics.html#edef-U so won't validate.

Use styles instead. Maybe a <span> tag. Although, if you want the thing you're trying to add an underline to, to be emphasized without styles enabled. Use an <em> tag and use CSS to give it an underline.

与往事干杯 2024-08-25 20:51:40

是的,它已被弃用。请改用样式。另请注意,带下划线的文本可能会令人困惑,因为它类似于链接的默认样式,并且可能会让某些用户感到沮丧。

如果您愿意,您甚至可以重新调整另一个 HTML 元素的用途,例如 em

CSS:

em {
  font-style: normal;         /* Removes italics */
  text-decoration: underline; /* Makes underline */
}

HTML:

<p>I like to <em>underline</em> words.</p>

Yes, it's deprecated. Use styles instead. Note also that underlined text can be confusing, as it resembles the default styling of links, and might frustrate some users.

If you wanted, you could even repurpose another HTML element, like em:

CSS:

em {
  font-style: normal;         /* Removes italics */
  text-decoration: underline; /* Makes underline */
}

HTML:

<p>I like to <em>underline</em> words.</p>
澜川若宁 2024-08-25 20:51:40

<咆哮>

关于“语义与风格”的一般评论:虽然这确实有道理,但这是一些人学得太多的教训。

在现实生活中,许多人使用斜体来强调。当然,我可以创建一个 CSS 样式“span.emphasized { font-style: italic;}”,然后代替“”在强调文本周围放置“”。除了大量额外的打字之外,这到底能带来什么好处?

此外,有一百万个理由让我想把一段文字用斜体字表示。也许这是一本书的书名;或许我想强调一下;也许我正在使用外来词斜体的惯例;如果我在文档中有 10 个单词由于 9 个不同的原因而变成斜体,那么迂腐的答案是我应该创建 9 个不同的 CSS 样式条目来描述所有这些原因。就我个人而言,我几乎从不这样做,因为它没有任何收获。是的,从理论上讲,我可能会决定书名应该采用草书字体,而不是斜体或类似字体。实际上,发生这种情况的概率非常接近于零,如果发生了,并且我的文档中有两个这样的书名,我只需更改两次即可。理论上,有人可能想用查找书名的程序扫描我的文本。但实际上,除非我们提前安排好,并且就 CSS 类名达成一致,否则他们不可能这样做。

我并不是说 CSS 没有用。恰恰相反。当我有一个语义对象在我的文本中重复多次,并且没有“自然”的、广泛认可的风格时,那么很可能会认为,当我继续处理文档时,我可能想要更改风格。在这种情况下,更改单个 CSS 条目比更改一百个实例要容易得多。或者我可能想在不同的情况下使用不同的样式,例如在屏幕上显示时将警告消息以红色显示,但在打印黑白文档时将其以粗体显示。

例如,我经常使用 CSS 来引用引文,因为我经常改变对斜体、缩进和字体大小的想法。我从不使用 CSS 来表示想要用斜体强调的文本,因为我知道我极不可能将其呈现为斜体以外的任何内容。

我的观点是,我不在乎某些学究说“这是一条你必须始终遵守的规则。你问为什么必须遵守它?但我只是告诉你!因为这是一条规则!”我使用在本应用程序中有用的工具和技术。 ,是的,有很多经验法则在 99% 的情况下都有效,并且在出现罕见的例外之前不值得考虑。)

(是的

<rant>

General comment on "semantics versus style": While there is certainly truth to this, it is a lesson that some people have way way overlearned.

In real life, many people use italics for emphasis. Sure, I could create a CSS style of "span.emphasized { font-style: italic;}", and then instead of putting "<i></i>" around the emphasized text, put "<span class='emphasized'></span>". And exactly what does that gain, besides a lot of extra typing?

Further, there are a million reasons why I might want to put a piece of text in, say, italics. Perhaps it is the title of a book; perhaps I want to emphasize it; perhaps I am using the convention of italicizing foreign words; etc. If I have 10 words in a document that are italicized for 9 different reasons, the pedantic answer is that I should create 9 different CSS style entries to describe all these reasons. Personally, I almost never do this, because it gains nothing. Yes, theoretically I might decide that book titles should be in a cursive font instead of italicized or some such. In practice, the probability that this will happen is pretty close to zero, and if it did, and I have two such book titles in my document, I can just change it twice. Theoretically someone might want to scan my text with a program that looks for book titles. But in practice, unless we have arranged this in advance and we have agreed on the CSS class names, there is no way they are going to do this.

I'm not saying CSS is useless. Quite the contrary. When I have a semantic object that is repeated many times in my text, and which has no "natural", widely-recognized style, it then becomes quite plausible to suppose that as I continue to work on the document I may want to change the style. In that case it is much easier to change a single CSS entry than to change a hundred instances. Or I may want to use a different style in different situations, like put warning messages in red when displaying on the screen but put them in bold when printing a black-and-white document.

For example, I routinely use CSS for quote citations because I often change my mind about italicizing, indenting, and font size. I never use CSS for text that I want italicized for emphasis because I know it is extremely unlikely that I will ever want to render this as anything other than italics.

My point is, I don't care that some pedant said "This is a rule that you must always obey. You ask why you must obey it? But I just told you! Because it's a rule!" I use tools and techniques that are useful in the present application. (And yes, yes, there are lots of rules of thumb that are valid 99% of the time and aren't worth thinking about until the rare exception turns up.)

</rant>

尬尬 2024-08-25 20:51:40

标签已被弃用,取而代之的是样式表。

大多数浏览器将在未来很长一段时间内继续识别它,只是出于向后兼容的需要内容已经存在。但如果你想通过 XHTML 兼容,你应该避免使用它。,

你可以阅读更多关于 此处已弃用 HTML 标记

The <u> tag has been deprecated in favor of stylesheets.

Most browsers will continue to recognize it for a long time to come, simply out of need to be backwards compatible with the content already out there. But if you want to by XHTML compliant, you should avoid using it.,

You can read some more about deprecated HTML tags here.

吲‖鸣 2024-08-25 20:51:40

是的,它在 HTML 4 中已被弃用。但是,您可以只使用以下 css。

span.underline { text-decoration: underline; }

然而,下划线的类名不是语义的。您可能需要将其替换为描述您需要下划线的内容的类名称。

Yes, it was deprecated in HTML 4. However, you can just use the following css.

span.underline { text-decoration: underline; }

However, the underline class name is not semantic. You may want to replace it with a class name that describes the content you need underlined.

夜深人未静 2024-08-25 20:51:40

该标签已被弃用,但并未过时。它没有过时的原因是允许浏览器支持该元素以实现向后兼容性。

该标记未在 xhtml1-strict.dtd 中定义,但可在 xhtml1-frameset.dtdxhtml1-transitional.dtd 下使用。它的声明如下(不是严格的 DTD):

<!ELEMENT u %Inline;>   <!-- underline -->
<!ATTLIST u %attrs;>

这是为了允许与浏览器向后兼容。

请勿使用该标记,因为“此标记已被弃用,取而代之的是样式表”。它可能很快就会过时。而是使用样式表,例如

/** Underlining an anchor tag in CSS **/
a {
    text-decoration: underline;
}

The tag is deprecated but not obsolete. The reason it's not obsolete is to allow browsers to support the element for backward compatibility.

The tag is not defined in the xhtml1-strict.dtd but it's available under xhtml1-frameset.dtd and xhtml1-transitional.dtd. It's declaration are as follows (not on Strict DTD):

<!ELEMENT u %Inline;>   <!-- underline -->
<!ATTLIST u %attrs;>

This is to allow backward compatibility with browsers.

Do not use the tag as "This tag has been deprecated in favor of style sheets". It may soon become obsolete. Rather use stylesheet, e.g.

/** Underlining an anchor tag in CSS **/
a {
    text-decoration: underline;
}
噩梦成真你也成魔 2024-08-25 20:51:40

已弃用:是的。
已验证:?我想这取决于你用什么来验证它。

http://www.codehelp.co.uk/html/deprecated.html

Deprecated: yes.
Validated: ? I guess that depends on what you are using to validate it.

http://www.codehelp.co.uk/html/deprecated.html

撩起发的微风 2024-08-25 20:51:40

是的,它已被弃用。

Yes, it is deprecated.

尘曦 2024-08-25 20:51:40

您使用 XHTML 和 HTML 标记了您的问题。 U 标签在 xhtml-strict 中肯定已被弃用。我认为在 HTML-4-Transitional 中可能还是可以的。正如其他人所说,请使用样式。有了好名字,它们就可以为您的文档提供更多语义。

You tagged your question with both XHTML and HTML. the U tag is definitely deprecated in xhtml-strict. I think it may still be OK in HTML-4-Transitional. As other people have said, use styles instead. With good name they give more semantics to your docs.

天暗了我发光 2024-08-25 20:51:40

如果您使用的是最新版本的 HTML 或 XHTML,那么它已被弃用。
无论如何,一般来说,您希望避免在不是链接的任何内容下划线,因为它会让用户更加困惑。

If you're using the latest version of HTML or XHTML then yes it's deprecated.
Regardless, in general you want to avoid underlining anything that isn't a link, as it can make things more confusing for the user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文