我们是否应该始终考虑没有 CSS 时页面的外观?
如果是,那么表现元素在这种情况下会很有帮助,那么我们应该使用这些元素吗?
<b>…</b> , <i>…</i>, <big>…</big>, <small>…</small>, <tt>…</tt>, <hr />
这些是有效的标签
If yes then presentational elements would be helpful in this condition so should we use those?
<b>…</b> , <i>…</i>, <big>…</big>, <small>…</small>, <tt>…</tt>, <hr />
These are valid tags
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
页面应该语义标记,而不是为了展示。如果您在元素上放置适当的语义标记,浏览器通常会自行对它们应用基本样式。您不应该关心文档看起来如何无样式。如果它是无样式,那么它就没有样式。 CSS 负责样式。如果用户选择查看没有样式的文档,那就这样吧。
The page should be marked up semantically, not for its presentation. If you put proper semantic markup on elements, the browser will usually apply a basic style to them by itself. You should not be concerned with how the document looks unstyled. If it's unstyled, it has no style. CSS is responsible for the style. If a user chooses to view the document without style, let it be so.
通常,(“普通”)用户无法像禁用 JavaScript 那样简单地禁用 CSS。
所以我会回答否。
CSS 是演示文稿的一部分,当CSS 不可用时,我们应该认为演示文稿不可用。因此客户端坏了。
您不应该担心这一点,因为您不想调试滥用演示文稿的客户端。
但是,如果您需要支持非标准设备(可能是旧手机),这是一个合理的担忧。不过,您不应将页面更改为“适合所有尺寸”,而应该为此类设备创建一个单独的页面。
不确定
tt
(我想你可以使用)。但
b
、i
应分别替换为strong
和em
。IMO 不应使用
big
和small
,而应根据语义用替代标签替换。Generally a ("normal") user cannot disable CSS as easy as JavaScript.
So I would answer NO.
CSS is a part of the presentation and when the CSS is not available we should think that the presentation is not available. Thus the client side is broken.
You should not be concerned about that as you don't want to debug a client abusing the presentation.
BUT, if you need to support non-standard devices (old mobiles maybe) this is a valid concern. Still instead of changing the page to "fit all sizes", you should have a separate page for such devices.
Not sure about
tt
(I guess you can use).But
b
,i
should be replaced bystrong
andem
respectively.big
andsmall
should not be used IMO and be replaced by alternative tags depending on the semantics.从技术上讲,您几乎可以使用
和
标签创建整个页面。但这会很混乱,而且不太直观。就我个人而言,我发现您列出的标签使人们更容易解析页面试图传达的内容,同时还提供了在 CSS 未加载时使页面可读的好处。
Technically, you could pretty much create an entire page using
<div>
and<span>
tags. That would just be messy though, and not very intuitive. Personally, I find that the tags you list make it easier for a human to parse what the page is attempting to communicate, while also offering the benefit of making a page readable when the CSS doesn't load.听起来你好像在问是否应该使用像
这样的标签,这样,在没有 CSS 的情况下,你想要小的东西就会很小。
不。
考虑没有 CSS 时页面的外观的原因是要了解您是否使用了良好的语义布局。如果它可用,那么您的 HTML(仅在设计时考虑了语义组织)是可以的。就是这样。如果您的用户出于某种原因不想支持 CSS 之类的演示性内容,请不要使用演示性标签。
而且,真的。如果您的用户出于某种原因没有 CSS,他们就不应该看到如此粗体的内容。这对你来说是更多的工作,它不是语义上的,而且没有人会关心。
It sounds like you're asking if you should use tags like
<small>
so that, in the absence of CSS, what you want to be small will be small.No.
The reason to consider how the page will look without CSS is to know if you are using good semantic layout. If it's usable, your HTML, which is only designed with semantic organization in mind, is okay. That's it. If your users, for whatever reason, don't want to support presentational things like CSS, don't use presentational tags.
And, really. If your users don't have CSS for whatever reason, they don't deserve to see something as bold. It's more work for you, it's not semantic, and no one will ever care.