English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML <main>标签是一个HTML5元素,用于定义HTML文档中的主要内容,并且文档中应该只有一个 <main>元素。此标签通常也称为 <main>元素。
在HTML中,<main>标记的语法为:
<body> <main role="main"> <h1>oldtoolbag.com</h1> <p>您可信赖的学习新技术的资源</p> <article> <h2>HTML</h2> <p>通过我们的分步教程和参考资料学习HTML(超文本标记语言)。</p> </article> <article> <h2>CSS</h2> <p>通过我们的分步教程和参考资料学习CSS(级联样式表)。</p> </article> </main> </body>
IEFirefoxOperaChromeSafari
所有主流浏览器都支持 <main> 标签。
!doctype html> <html> <head> <meta charset="UTF-8"> <title>HTML5 main标签的使用(基础教程网 oldtoolbag.com)</title> </head> <body> <main role="main"> <h1>oldtoolbag.com</h1> <p>您可信赖的学习新技术的资源.</p> <article> <h2>HTML</h2> <p>通过我们的分步教程和参考资料学习HTML(超文本标记语言)。</p> </article> <article> <h2>CSS</h2> <p>通过我们的分步教程和参考资料学习CSS(级联样式表)。</p> </article> </main> </body> </html>Test see ‹/›
The HTML <main> element is found within the <body> tag5elements.
The <main> tag should not be used for repetitive content, such as navigation, website logos, social media links, copyright information, and sidebars.
It is recommended to use the ARIA role "main" on the <main> element so that screen readers in old browsers can access it, for example: <main role="main">
for IE versions earlier than 9for IE browsers, please use HTML5shiv, which is a JavaScript solution that can provide support for new HTML5elements are supported, such as: <header>, <main>, <article>, <section>, <aside>, <nav>, <footer>.
In the document, the content of the <main> element should be unique. Any identical or duplicate content that exists in any series of documents, such as sidebars, navigation bar links, copyright information, website logos, search boxes (unless the search box is the main function of the document), should not be included within it.