HTML 5 语义
我已经阅读了一段时间有关 HTML 5 的正确语义的内容,但仍然不确定某些事情。
我的网站从数据库输出如下:
- 标题(当前使用
)
- 描述(当前使用
)
- 图像(当前使用
<
) img> 并且没有包装元素) - 打开/关闭(当前使用
)
- 服务
- 苹果酒(是/否)
- 葡萄酒(是/否)
- 草稿(是/否)
我对此感到非常困惑:
每个结果
现在是否应该在 内
元素,因此页面将在
内输出 10 个结果,或者使用 1 在 html5 语义上正确
包含结果,因为它是结果
并且每个结果都保存在
中;
???谢谢
I've been reading for a while now about the correct semantics of HTML 5 and am not sure about some things still.
My website outputs from the database like so:
- Title (currently using
<h2>
) - Descrption (currently using
<p>
) - Image (currently using
<img>
and no wrapper element) - Open/Close (currently using
<p>
) - Services
- cider (yes/no)
- wine (yes/no)
- draft (yes/no)
I am very confused with this:
should each result <div>
now be within a <section>
element, so a page would output 10 results all within a <section>
, or would it be html5 semantically correct using 1 <section>
to contain the results as it is a results <section>
and each result is held within a <div id="unique_number">
???
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
部分是内容的主题分组,通常带有标题。
在您的情况下,我会为每个结果使用一个部分。
示例:
参考: http://dev.w3.org/html5 /spec/Overview.html#the-section-element
A section is a thematic grouping of content, typically with a heading.
I would use a section foreach result in your case.
Example:
Reference: http://dev.w3.org/html5/spec/Overview.html#the-section-element
网页的标题应设置在
Title
(位于中)以及页面上(在
body
)和。这对语义和 SEO 都很友好。
如果“描述”是独立的,则可以是
。
如果它是其他文本的一部分,则段落很好,但通常段落不会单独存在,因此请使用如果是这样的话。图片:这要看情况。如果此图像纯粹用于样式(可能是背景中的漩涡或渐变),则应将其设置为 CSS 中元素的背景图像。如果它是实际内容(如徽标、照片),则使用
标记。
我猜“打开”和“关闭”是交互元素、链接或按钮。如果是这样,请使用
The title of a web page should be set in the
<title>Title</title>
(located in<head>
) as well as on the page (in thebody
) with an<h1>
. This is both semantic and SEO friendly.The "description", if it stands alone, could be a
<span>.
If it's part of some other text, a paragraph is good, but generally paragraphs don't stand alone, so use a span if that's the case.Image: it depends. If this image is purely for styling - perhaps a swirl in the backround or a gradient - it should be set as the background-image of an element in CSS. If it's actual content (like a logo, photo), then use the
<img>
tag.I'm going to guess "Open" and "Close" are interactive elements, links, or buttons. If so, use a
<button>
or an anchor:<a>
, not a paragraph. If these are headings, use one of the heading tags. Since you've used<h1>
, then use<h2>
(unless it's not a very important heading)As to your "Results", according to the spec,
Additionally,
So in your case, a
<div>
for search results is probably fine.