是否可以创建 html 标签 h7、h8、h9 等
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22638799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to create html tags h7, h8, h9 and so on
提问by user3380148
Here's a novice question. Is it possible to create more heading styles like h7, h8, and so on. I am just wondering if it possible to have more than 6 different types of headings on a website.
这是一个新手问题。是否可以创建更多的标题样式,如 h7、h8 等。我只是想知道网站上是否有可能有超过 6 种不同类型的标题。
采纳答案by Palpatim
You can create any element you want on a page, but I think your question is whether it will be interpreted correctly by a user agent like a browser. Browsers will allow you to create, apply styles to, and access arbitrarily-created elements on the DOM regardless of whether they conform to the spec implied by your declared DOCTYPE
.
您可以在页面上创建任何您想要的元素,但我认为您的问题是它是否会被像浏览器这样的用户代理正确解释。浏览器将允许您在 DOM 上创建、应用样式和访问任意创建的元素,无论它们是否符合您声明的DOCTYPE
.
However, in general, it's best to avoid creating deeply nested structures; users find such hierarchies difficult to follow. In addition, as other answers linked in the comments have pointed out, there may be unintended consequences with page accessibility, SEO, or script compatibility. I have yet to find a use case that actually needs such deeply nested hierarchies, except when posting long legal documents as a single HTML page.
但是,一般来说,最好避免创建深度嵌套的结构;用户发现这种层次结构难以遵循。此外,正如评论中链接的其他答案所指出的那样,页面可访问性、搜索引擎优化或脚本兼容性可能会产生意想不到的后果。我还没有找到真正需要如此深层次嵌套层次结构的用例,除非将长法律文档作为单个 HTML 页面发布。
回答by somebodysomewhere
The HTML spec defines 6 headings. Browsers recognize 6 headings. If you start using <h7>
and so on, then you'll be using an invalid element.
HTML 规范定义了 6 个标题。浏览器识别 6 个标题。如果您开始使用<h7>
等等,那么您将使用无效元素。
If you find yourself needing an <h7>
then you should probably take a look at how you're structuring your site. Not every single title deserves a heading element.
如果你发现自己需要一个,<h7>
那么你应该看看你是如何构建你的站点的。并非每个标题都应该有标题元素。
回答by LOTUSMS
Generally speaking you can create as many headings as you want but they must be defined as classes. So if you are looking at making more than 6 headings for organization purposes do something like :
一般来说,您可以根据需要创建任意数量的标题,但它们必须定义为类。因此,如果您出于组织目的考虑制作 6 个以上的标题,请执行以下操作:
.h7{
color: #111111;
font-size: 16px;
text-transform: uppercase;
}
<p class="h7"> I'm an extra heading </p>