HTML5/CSS3系列教程:HTML5基本标签使用header,nav和footer
大家可能都知道HTML5中出现了很多以前没有的标签,例如,header,nav,和footer,在这之前我们如果开发相关的页面布局的时候,往往都是使用CSS来定义相关的头部,导航及其页底部分,如下:
#nav{ padding: 10px... } #header{ padding: 10px ... } #footer{ padding: 10px ... }
定义完之后呢,我们使用p标签来组织页面结构,如下:
<div id=“header”></div> <div id=“nav”></div> <div id=“footer”></div>
这样的代码让我们创建了很多的非样式的CSS定义,是的代码结构复杂并且不直观易懂。
在新的HTML5标准中,我们定义了一系列的标签,帮助你更语义化的定义页面层次和逻辑,你不需要自己定义相关的DIV,HTML5提供了现成的标签来完成上述的结构化定义,如下:
<header></header> <nav></nav> <footer></footer>
使用以上的标签,你只需要在css文件中定义相关的真正的样式信息即可。
在今天的这篇文章中,我们将介绍相关的基本HTML5标签Header,nav和footer。
header标签
在新的标准中header标签定义如下:
“A group of introductory or navigational aids.”
基本意思是“一组介绍性的护着导航相关的辅助内容”。字面上理解header标签不单单只是定义页头内容,也可以定义页头以下其它内容的介绍。这和我们传统的页面header定义并不完全一致。例如:
<header> <h1>HTML5基本标签使用,header,Nav和footer</h1> <div class=”post-meta“> <p>作者信息:gbin1.com</a> <span class=”category“>文章创建类别:HTML5/CSS3</span></p> </div> </header> <article> <p>大家可能都知道HTML5中出现了很多以前没有的标签,例如,header,nav,和footer, 在这之前我们如果开发相关的页面布局的时候,往往都是使用CSS来定义相关的头部,导航及其页底部分</p> </article>
在上面的结构中,我们可以看到使用header我们定义了一篇文章的标题和内容。这里header标签的使用并不是页面的页头,而是文章的页头。
所以在HTML5中,header的使用更加灵活,你可以根据你的需要来定义和组织document结构。
Nav标签
Nav标签全称navigation,顾名思义,是导航的意思。根据HTML5的相关标准定义如下:
"A section of a page that links to other pages or to parts within the page: a section with navigation links."
中文翻译大概意思是”页面中的一个用来链接到其它页面或者当前页面的区域:一个含有导航链接的区域”。
这里非常清楚的定义了nav标签的功能,这里和header类似并没有指定必须是主导航,也可以是页面其它部分的子导航。如下:
<h3>gbin1.com文章列表</h3> <nav> <ul> <li><a href=”#html5“>HTML5文章介绍</a></li> <li><a href=”#css3“>CSS3文章介绍</a></li> <li><a href=”#jquery“>jQuery文章介绍</a></li> <ul> </nav>
在上面这个例子中,我们看到这里只是一个区域的文章导航,同样也可以使用nav定义一个小型的页面内导航。
Footer标签
最后一个就是footer标签,即,页底标签。使用这个标签你可以定义页面的低端结构,当然,和上面我们介绍header标签或者nav标签一样,它并不是仅仅使用在整个页面的页尾处。相关的HTML5标准定义如下:
“ The footer element represents a footer for its nearest ancestor sectioning content or sectioning root element. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.”
中文意思是:”footer元素代表了页面内容或者区域内容最底端的展示。一个典型的例子是包含了作者信息,文档链接或者是版权信息等等“。
当然,这里我们看到并不局限于整个页面的内容,也可以是一个文章的页尾内容,例如,来源或者是作者信息等等。如下:
<footer> <div class=”tags“> <span class=”tags-title“>相关标签</span> <a href=”#“ rel=”tag“>html5</a>, <a href=”#“ rel=”tag“>nav</a>, <a href=”#“ rel=”tag“>header</a>, <a href=”#“ rel=”tag“>footer</a> </div> <div class=”source“> <div>来源:<a href=”http://gbin1.com“>html5/css3教程</a></div> </div> </footer>
在上面的例子中,我们定义了一个简单的文章内的页尾信息,可以看到我们添加了来源和相关标签,这在博客类型的网站中经常出现。
一个完整的HTML5页面
在这里我们使用基本的header,nav和footer标签书写了一个响应式的HTML5页面,如果你使用老版本的浏览器,例如IE6,7等等。需要引入相关的js来帮助识别新的元素,当然,你也可以使用下面js代码来简单生成。
/* * 创建HTML5标签 */ document.createElement(”article“); document.createElement(”section“);
总结
相 对于其它的HTML5特性来说,header,nav和footer显得不是那么的酷,当时作为一个前端开发人员来说,如何能够正确的组织页面结构对于一 个逻辑性很强,页面也很复杂的项目来说,意义依旧是非常重大的。希望今天的这篇文章能够帮助大家简单直观的了解这些基本的HTML5标签。
以上就是HTML5/CSS3系列教程:HTML5基本标签使用header,nav和footer的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

H5 page production refers to the creation of cross-platform compatible web pages using technologies such as HTML5, CSS3 and JavaScript. Its core lies in the browser's parsing code, rendering structure, style and interactive functions. Common technologies include animation effects, responsive design, and data interaction. To avoid errors, developers should be debugged; performance optimization and best practices include image format optimization, request reduction and code specifications, etc. to improve loading speed and code quality.

The steps to create an H5 click icon include: preparing a square source image in the image editing software. Add interactivity in the H5 editor and set the click event. Create a hotspot that covers the entire icon. Set the action of click events, such as jumping to the page or triggering animation. Export H5 documents as HTML, CSS, and JavaScript files. Deploy the exported files to a website or other platform.

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

H5 is not a standalone programming language, but a collection of HTML5, CSS3 and JavaScript for building modern web applications. 1. HTML5 defines the web page structure and content, and provides new tags and APIs. 2. CSS3 controls style and layout, and introduces new features such as animation. 3. JavaScript implements dynamic interaction and enhances functions through DOM operations and asynchronous requests.

Yes, H5 page production is an important implementation method for front-end development, involving core technologies such as HTML, CSS and JavaScript. Developers build dynamic and powerful H5 pages by cleverly combining these technologies, such as using the <canvas> tag to draw graphics or using JavaScript to control interaction behavior.

H5 (HTML5) is suitable for lightweight applications, such as marketing campaign pages, product display pages and corporate promotion micro-websites. Its advantages lie in cross-platformity and rich interactivity, but its limitations lie in complex interactions and animations, local resource access and offline capabilities.

H5 pop-up window creation steps: 1. Determine the triggering method (click, time, exit, scroll); 2. Design content (title, text, action button); 3. Set style (size, color, font, background); 4. Implement code (HTML, CSS, JavaScript); 5. Test and deployment.
