search
HomeWeb Front-endH5 TutorialDetailed explanation of examples of main element in h5

As early as 2013, the

element was officially added to the W3C HTML specification. Up to now, the definition of this element has been very complete, so now it is time to take a deeper look at when it is appropriate to use

 W3C specification

 The main purpose of

is to map ARIA's landmark function main to elements in HTML. This helps screen readers and assistive devices know where the main content of the page begins. The W3C specification describes
as:

The main content of a document or application. The main content area consists of content that directly relates to or extends to the central topic of the document or the core functionality of the app.

Since the

element was included in the HTML specification, the element has reverted to its HTML4 definition.

The body element represents the content of the document.

Details

It is noteworthy to use the

element One thing is, it can only be used once per page. Why is it stipulated that a page can only be used once? Although I'm not interested in the specific details, some of the points seem to make sense.

According to the specification, if you try to use multiple

tags in a document, the W3C validator will throw an error.

Another requirement for the

element is that it cannot be used as a child element node of
,
,

Use

Just like other new HTML5 elements, not all browsers can recognize

and add preset styles to it. You may need to Make it a block-level element in its own CSS file.

    main {display:block;}

Sometimes, in order to support some lower versions of IE browsers, you may also need to use JavaScript to create this element.

<script type="text/javascript">document.createElement(&#39;main&#39;);</script>

Of course, you can also use html5shiv.

The easiest way to use the

element is to replace the

So, what should it look like in practice? Below is the structure of the document before using the

element.

    <header>Header</header>
    <p id="content">Main Content</p>
    <footer>Footer</footer>

The following uses the

element to rewrite the document.

    <header>Header</header>
    <main id="content">Main Content</main>
    <footer>Footer</footer>

Okay, this is so simple that in less than a minute we can rewrite the document into the latest HTML5 style.

Summary

As you can see, using the

element is super easy and only takes a few minutes, so now it’s really time to bring in the
It’s time for website development.

The above is the detailed content of Detailed explanation of examples of main element in h5. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
电脑main什么意思电脑main什么意思Jan 19, 2021 pm 02:57 PM

电脑main在计算机软件中代表主菜单或者主类。一些桌面软件,都会有一个主菜单,包含基本的操作菜单,命名为main;而在开发语言java、c语言等高级语言中,都会存在一个main的主类,是程序执行的入口。一个程序可以有多个函数,但只能有一个main()函数。

linux内核有main函数吗linux内核有main函数吗Mar 28, 2023 am 10:45 AM

linux内核有main函数;main函数是程序的入口,main是应用程序和操作系统之间约定好的一个接口名,所以linux中每个应用程序的第一个函数必须是main。

h5是指什么h5是指什么Aug 02, 2023 pm 01:52 PM

H5是指HTML5,是HTML的最新版本,H5是一个功能强大的标记语言,为开发者提供了更多的选择和创造空间,它的出现推动了Web技术的发展,使得网页的交互和效果更加出色,随着H5技术的逐渐成熟和普及,相信它将会在互联网的世界中发挥越来越重要的作用。

MAIN是什么接口MAIN是什么接口Mar 06, 2023 am 11:50 AM

MAIN是主天线接口,而aux是辅助天线接口;大部分英特尔无线网卡主板只有数字1、2、3,其中标识的main数字为1(连灰线),aux数字为2(连黑线),如果有3,一般连白线。

如何区分H5,WEB前端,大前端,WEB全栈?如何区分H5,WEB前端,大前端,WEB全栈?Aug 03, 2022 pm 04:00 PM

本文带你快速区分H5、WEB前端、大前端、WEB全栈,希望对需要的朋友有所帮助!

h5如何使用positionh5如何使用positionDec 26, 2023 pm 01:39 PM

在H5中使用position属性可以通过CSS来控制元素的定位方式:1、相对定位relative,语法为“style="position: relative;”;2、绝对定位absolute,语法为“style="position: absolute;”;3、固定定位fixed,语法为“style="position: fixed;”等等。

h5怎么实现web端向上滑动加载下一页h5怎么实现web端向上滑动加载下一页Mar 11, 2024 am 10:26 AM

实现步骤:1、监听页面的滚动事件;2、判断滚动到页面底部;3、加载下一页数据;4、更新页面滚动位置即可。

Java中的main函数有什么用Java中的main函数有什么用May 04, 2023 am 09:34 AM

主函数的一般写法如下:publicstaticvoidmain(String[]args){&hellip;}下面分别解释这些关键字的作用:(1)public关键字,这个好理解,声明主函数为public就是告诉其他的类可以访问这个函数。(2)static关键字,告知编译器main函数是一个静态函数。也就是说main函数中的代码是存储在静态存储区的,即当定义了类以后这段代码就已经存在了。如果main()方法没有使用static修饰符,那么编译不会出错,但是如果你试图执行该程序将会报错,提示

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!