html 页面上常见结构/语义类/id 的典型名称?
我想知道网页上各种常见元素的标准或共性,这些元素尚未与其关联。我经常很难说出页面的某些元素。
我肯定知道 html 5 中包含的内容:
- 页眉导航
- 部分
- 文章
- 旁边
- 页脚
- 但是
我应该称呼什么为:
- 像块引用一样突出显示的文本块,但实际上并不引用任何内容 - 基本上就像块强调一样。或者我应该只使用块引用?
- 主页上的一个部分,其中有不同的块,例如列出不同的功能。
- 另一个元素的弹出文本描述(可能会出现在悬停时,但对于结构/样式划分可能不需要这样做)
- 主页上的介绍性描述(介绍?)
我知道这些本身不是技术考虑因素,并且我可以用我的大脑为它们想出自己的名字,但我想知道是否有行业惯例/最佳实践已经成为页面不同部分的标准,只是为了让我的代码更清晰。我尝试过寻找纲要,但没有发现太多用处。
I'm wondering about standards or commonalities for various common elements on webpages that have no specific element already associated with them. I often struggle to name certain elements of a page.
I know about the ones included in html 5 for sure:
- Header
- Nav
- Section
- Article
- Aside
- Footer
But what should I call:
- A highlighted block of text like a blockquote, but not actually quoting anything--basically like a block emphasis. Or should I just use blockquote?
- a section on a homepage where there are distinct blocks for, say, listing different features.
- a pop-up text description of another element (that might appear on hover, but for structure/style division should probably not require that)
- the introductory description on the homepage (intro?)
I know these aren't technical considerations per se, and I can just come up with my own names for them using my brain, but I wonder if there are industry conventions/best practices that have become standard for different parts of pages just to make my code more legible. I've tried searching for a rundown, but haven't found much of use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,您会看到“列”和“行”使用得很多,仅举两个例子。
关于您的其他问题:
突出显示的文本块,例如块引用:您可以使用块引用,根据经验,您应该尽可能尝试使用适当的标准 html 元素,以保持简洁。否则,您可以使用“突出显示”类并相应地更改您的 css,这样,如果您在两年后回到它,您就会确切地知道它的含义。
主页上的一个部分,其中有不同的块,例如列出不同的功能:您在这里已经回答了自己的问题。列表对于这类事情非常流行,
元素上可能有一个类或 id。以描述性且简洁的方式命名。这样做,您不需要想出一个新术语。
另一个元素的弹出文本描述:您会看到
popup
使用很多,例如主页上的介绍性描述:我对此没有任何建议,您可以将其作为一个。标准
并根据其父级对其进行样式设置,对于第一段来说,像
#content p:first-child
这样的解决方案比特殊的解决方案更好。类,在我看来。Well, you see "column" and "row" used a lot, to name two.
Regarding your other questions:
Highlighted block of text like a blockquote: well you could use a blockquote, as a rule of thumb, you should always try and use an appropriate standard html element when you can, to keep things clean. Otherwise, you could use a class "highlight" and alter your css accordingly, so you'll know exactly what it means if you come back to it in two years.
A section on a homepage where there are distinct blocks for, say, listing different features: you've kind of answered your own question here. Lists are very popular for this sort of thing, with maybe a class or id on the
<ul>
element. Name it in a descriptive yet concise way. Doing that, you don't need to come up with a new term.A pop-up text description of another element: you see
popup
used a lot, for example<div class=
popup">..content..` . This works well when the popup is a child of the hovered element, for easy DOM traversal.The introductory description on the homepage: this one I don't have any suggestions for. Your suggestion of intro is fine. You could just have it as a standard
<p>
and style it based on it's parents. A definition like#content p:first-child
would be a nicer solution for a first paragraph of many than a special class, in my opinion.