使用未列为已弃用的 W3C 有效表示元素有哪些实际缺点?

发布于 2024-08-21 02:02:04 字数 1075 浏览 7 评论 0原文

使用 W3C 有效的表示元素(未列为已弃用)有哪些实际缺点

  • 对于 XHTML-CSS 开发人员、
  • 网站的视力终端用户
  • 和屏幕阅读器用户来说,

?如


、< code> 如果我将这些标签用于演示目的。 (注意: HTML 5 也支持这些

例如:

  1. 如果我使用代替
  2. 如果我使用 代替
  3. 如果我使用
    在段落中换行而不是腾出空间
  4. 如果我使用
    代替
  5. 如果我使用 代替

我知道 之间的区别;。我的问题不是关于

What are practical cons to use W3C valid presentational element, which are not listed as deprecated

  • for XHTML-CSS developers,
  • Sighted End users of site,
  • and for Screen reader users, ?

like <b> , <i>, <br>, <hr>, <small> If i use these tags for presentational purpose. (note: these are also supported in HTML 5)

for example:

  1. If i use <b> in place of <span style="font-weight: bold">
  2. If i use <i> in place of <span style="font-style: italic">
  3. If i use <br> to make line break in paragrah not to make space
  4. If i use <hr> in place of <div style="border-bottom: 1px solid #666">
  5. If i use <small> in place of <span style="font-size: 9px">

I know the difference between <strong> and <b>. My question is not about <strong> vs <b>

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

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

发布评论

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

评论(5

相思故 2024-08-28 02:02:04

使用它们本身并没有“缺点”。使用它们做错误的事情是有“弊端”的。过去,它们经常在网页中被用于错误的用途,但这并不意味着没有正确的用途。

在语义上等价于:也就是说,没有语义内容。 ... 中的单词并不更重要;而是更重要。网页文本到语音转换器不应该(*)以强调的语气读出该单词。

当您想强调某个单词时,例如这句话中的“definitely”,您应该definitely使用。这是常见的情况。但是,当您只需要印刷细节时,例如仅出于视觉目的将一段文本设为斜体,或者印刷怪癖(例如始终将您的网站称为“ThingsWorld!”),; 不合适,您需要无语义版本()。

类似地, 适合上面的“for the bad thing”,因为它的意思是强烈强调。如果您只是希望部分文本以粗体呈现,而不暗示它比周围的文本更重要,您可以使用 或者,再次,在另一个元素上使用样式,例如

的常见用途是从非语义源获取文本。特别是从文字处理程序或类似应用程序导入内容是很常见的,其中没有强调的概念,只有“斜体”和“粗体”。在这种情况下, (或 span 等效项)是合适的,因为您不知道这些文本样式背后的语义意图是什么;该信息已经丢失。

如果您像许多工具一样将所有斜体自动转换为 ,则您可能会标记并不代表强调的斜体。例如,对其他作品的引用,最好用 标记,或者来自其他语言(例如拉丁语或法语)的单词/短语,最好用 < 标记;span lang> (以及告诉它来自另一种语言的单词的相关样式应该是斜体)。

理论上可能是相同的情况,但虽然导入的文本带有粗体/斜体很常见,但导入的大小文本则不然。因此,没有人使用这些标签,并且您通常最好使用正常的 CSS 字体大小样式。



可以说与上述标签的表现方式不同。换行符可能是内容的重要组成部分(例如,在地址中分隔行),并且水平线表示文本各部分之间比单纯段落更强的分隔。当然,如果您使用
创建假段落,那么您就做错了(您是 1998 年左右的 David Siegel),并且使用


只是为了得到一条漂亮的小线,但这也不正确。

(*:说明性示例;找出真正的屏幕阅读器实际执行的操作留给读者作为练习。)

There's not a ‘con’ to using them per se. There's a ‘con’ to using them for the wrong thing. They have often been used for the wrong thing in web pages in the past, but that doesn't mean there's no right thing.

<i> is semantically equivalent to <span style="font-style: italic">: that is to say, there is no semantic content. A word inside <i>...</i> is not more important; a web page text-to-speech converter shouldn't(*) read that word in an emphasised tone of voice.

When you want to emphasise a word, like ‘definitely’ in this sentence, you should definitely use <em>. This is the common case. But when you merely want a typographical detail, such as italicising a block of text just for visual purposes, or typographical quirks like always refering to your site as “ThingsWorld!”, <em> isn't suitable and you'd want the semantics-free version (the <i> or the <span>).

Similarly, <strong> is suitable for “for the wrong thing” above as it is meant to be strongly emphasised. If you just wanted part of the text to be rendered in bold, without implying that it is more important than the surrounding text, you'd use <b> or, again, styles on another element like <span> or <div>.

A common use for <i> and <b> is when you are taking text from an unsemantic source. In particular it is common to be importing content from a word processor or similar application where there is no concept of emphasis as such, only ‘italic’ and ‘bold’. In this case <i> and <b> (or the span equivalents) are appropriate, because you don't know what the semantic intent behind those text styles is; that information is already lost.

If you auto-converted all italics to <em> like many tools do, you might be marking up italics that aren't meant to represent emphasis. For example references to other works, which would be better marked up with <cite>, or words/phrases from another language such as Latin or French, which would be better marked up with <span lang> (and associated style to tell it words from another language should be italicised).

<small> and <big> might theoretically be the same case, but whilst imported text with bold/italic in is common, imported sized text isn't. Consequently no-one uses these tags and you're generally better off with the normal CSS font-size styles.

<br> and <hr> are arguably not presentational in the same way that the above tags are. A line break can be an important part of content (eg. in separating lines in an address), and a horizontal rule represents a stronger separation between sections of text than a mere paragraph. Of course if you use <br> to create fake paragraphs you're doing it wrong (and you're David Siegel circa 1998), and using an <hr> just to get a nice little line that's not right either.

(*: illustrative example; finding out what real screen readers actually do is left as an exercise for the reader.)

注定孤独终老 2024-08-28 02:02:04

为了完整起见,这里是 元素索引,列出了哪些已弃用和哪些不是(并且您正确地指出它们已弃用)。

一般来说,人们使用:

  • 而不是
  • 而不是



  • 因为没有其他选择;
  • 根据我的经验, 很少使用,而是使用 CSS 样式。

重要的是要理解 具有语义含义,但 ; 不要这样做,这样两者都有有效的用例。

For completeness here is the Index of Elements that lists which are deprecated and which aren't (and you are correct in stating them as not deprecated).

Generally speaking however people use:

  • <strong> instead of <b>;
  • <em> instead of <i>;
  • <hr> and <br> because there is no alternative;
  • <small> is in my experience rarely used, with CSS style being used instead.

It's important to understand that <strong> and <em> have semantic meaning but <b> and <i> do not so there are valid use cases for both.

野の 2024-08-28 02:02:04

hrs 在不添加更多 html 的情况下使用 CSS 进行样式设置是很痛苦的,

brs 只是让我烦恼,因为当你需要使用填充和边距时,它们并不是真正需要的

我倾向于使用 em 或 Strong 而不是 i 或 b - 这两者都意味着斜体或粗体而 em 或 Strong 更抽象一些,因此如果您想对某些文本进行“强调”或使某些文本看起来更强一些,它们会更有意义,而不必是粗体或斜体

hrs are a pain to style with CSS without adding more html

brs just annoy me as they are not really required when you having padding and margins to play with

I tend to use em or strong rather than i or b - both of these imply italic or bold whereas em or strong are a bit more abstract so if you want to give some 'em'phasis to some text or make some text look a bit stronger they make more sense without necessarily being bold or italic

找个人就嫁了吧 2024-08-28 02:02:04

使用
元素来指示换行符(因此不使用

元素来指示段落)的缺点是限制了范围CSS 对文档的控制。管理文本的许多

元素比通过 CSS 在一个元素中散布
文本要容易得多。

每当我将 HTML 文档放在一起时,我都会使用


  • 来表示“软”中断。
    (如上所述:而是在

    元素上使用边距
    显示段落。)




  • 表示两个部分的划分
    文件的,例如之间
    标题和导航,或导航
    和内容。当浏览器没有
    CSS支持查看文档,a
    明显的鸿沟是可见的。然后我通过 CSS 隐藏


The cons of using <br> elements to indicate line-breaks (and therefore not using <p> elements to indicate paragraphs) is that you're limiting your scope of CSS control over the document. It's much easier to manage many <p> elements of text, than text interspersed with <br>s in one element via CSS.

Whenever I put together am HTML document, I use

  • <br> to indicate a 'soft' break.
    (As above: rather use margins on <p> elements
    to show paragraphs.)
  • <hr> to
    indicate the division of two sections
    of the document, e.g. between the
    header and navigation, or navigation
    and content. When a browser without
    CSS support views the document, a
    clear divide is visible. I then hide the <hr>s via the CSS.
亢潮 2024-08-28 02:02:04

在你的 5 个例子中,我认为只有这个有意义:“# 如果我使用 代替

Small 是相对的,而 font-size:9px 是绝对的。我们应该始终使用相对单位,允许浏览器选择自己的绝对比例。 (或者最好是 )将是等效的。

Of your 5 examples, only this one, I think, has significance: "# If i use <small> in place of <span style="font-size:9px>"

Small is relative, whereas font-size:9px is absolute. We should always use relative units, allowing the browser to choose their own absolute scale. <span style="font-size:small"> (or preferably <span style="font-size:smaller">) would be the equivalent.

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