[英]Is there a length limit for a HTML heading? (h1, h2 etc)
Is it valid HTML5 to have a long sentence as a h2
? HTML5 有一个长句作为
h2
有效吗?
For example:例如:
<hgroup>
<h1>
Food & Drink Products
</h1>
<h2>
There are 5000 food products near you in 100 categories from brands like FoodX, DrinkY, and FoodStuffsZ.
</h2>
</hgroup>
Or would a p
tag more appropriate?还是
p
标签更合适?
I'm asking because the importance of this text is that of a h2
, but it reads like a paragraph and I could not find an example like this or any mention of heading length on the HTML spec .我问是因为这段文字的重要性是
h2
的重要性,但它读起来像一个段落,我找不到这样的例子,也找不到HTML 规范中标题长度的任何提及。
You should mark up your text based on what is appropriate for the content you are showing , according to most copy-writing and SEO guidelines.根据大多数文案写作和 SEO 指南,您应该根据适合您所显示内容的内容来标记您的文本。
There is no limit on heading length from a HTML perspective , but you need to consider it from other, arguably more important, perspectives:从 HTML 的角度来看标题长度没有限制,但是你需要从其他的,可以说更重要的角度考虑:
title
which is generally the same as the h1
. title
中的前60-70个字符,一般与h1
相同。 I don't know of any data about how they consider h2
or any other subheadings, but their aim is to appraise pages in the same way humans do.h2
或任何其他副标题的任何数据,但他们的目标是以与人类相同的方式评估页面。 So if they think that overly-long headings are not "user-friendly" then they might not rate it, or worse, penalise the page for attempting to "game" the SEO system. In summary : As I mentioned earlier, the advice for usability, SEO and general copywriting is to do what makes sense for your own content.总结:正如我之前提到的,对可用性、搜索引擎优化和一般文案写作的建议是做对你自己的内容有意义的事情。 So if it makes sense then do it, but in most cases there is no need for long heading and it could a sign that the text needs improvement, and a shorter version would probably work better:)
因此,如果它有意义,那就去做吧,但在大多数情况下,不需要长标题,它可能表明文本需要改进,而较短的版本可能会更好:)
In the example in your question , I wouldn't consider that text a heading - it sounds more like a paragraph.在您问题的示例中,我不会将该文本视为标题 - 它听起来更像是一个段落。 A heading would be something like " 5000 Food Products Near You in 100 Categories ", with the next text being info about the products and categories.
标题类似于“您附近的 5000 种食品,分为 100 个类别”,下一个文本是有关产品和类别的信息。
If you want to be precise, use h1
or h2
for headlines and p
for paragraphs.如果要精确,请使用
h1
或h2
作为标题,使用p
作为段落。 Long headlines are fine, there's no rule saying headlines shouldn't be long.标题长就好,没有规定标题不能长。
Also, truth of the matter is, it doesn't matter so much.而且,事情的真相是,这并不重要。 If you choose
p
over h2
, as long as it works well for you, that's fine.如果您选择
p
而不是h2
,只要它适合您,那很好。
There are far more important things, such as writing a responsive website, clean code, etc.还有更重要的事情,例如编写响应式网站、干净的代码等。
That definitely depends on what you want.这绝对取决于你想要什么。 If
h2
suffices for you use that.如果
h2
足以满足您的需求,请使用它。 I myself would prefer to use <p>
for that and then chance css for my liking.我自己更愿意为此使用
<p>
,然后根据自己的喜好使用 css。
There are no problems to use headers as a paragraph, but the question is for what?标题作为段落没有问题,但问题是为了什么? If you just want to highlight the text, use a
p
with a class, it is much better如果你只是想突出显示文本,使用带有 class 的
p
,它会好得多
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.