HTML5中的section标签是什么?HTML5中的section标签怎么居中?

HTML5中的section标签是什么?HTML5中的section标签怎么居中?本篇文章就详细地为大家举出了实例,方便大家的观看,其中的HTML5中section的定义和作用,都有实例在里面。(后面还有元素有话说

HTML5—新语义元素header、nav、section、article、aside、footer等

在HTML5中相对于以往版本的文档书写方面,追加了一些标签。如页眉、页脚、内容区等等的元素结构。其中在主体结构元素中增加了article及section元素。那么他们两个有什么区别呢,什么时候用article,什么是用section

什么是article:HTML5中的article标签是什么?HTML5中的article元素用在什么地方?

今天就让我们来讲讲新语义元素中的<section>元素的定义:

<section>:它定义文档中的节(section、区段)。比如章节、页眉、页脚或文档中的其他部分,section通常 包含了一组内容及其标题。

HTML5中section元素的作用:

section元素是对页面上的内容分块处理,例如对文章分段等,相邻的section元素的内容,应当是相关的,而不是像article那样独立。例如一篇文章:

<article>
      <header><h1>计算机各类语言介绍</h1></header>
      <p>本文列举了部分计算机语言的一些介绍</p>
      <section>
        <h2>JavaScript</h2>
        <p>js是一门……</p>
      </section>
      <section>
        <h2>HTML</h2>
        <p>HTML是一门……</p>
      </section>
      <footer>版权归微也所有</footer>
	  </article>

HTML5中的section标签怎么居中:

我是觉得使用css样式,text-align:center,这个来居中,来看看实例:

<!DOCTYPE HTML>
<html>
    <meta charset="UTF-8" />
    <head>
        <title>PHP中文网</title>
    </head>
    <script src="http://lwww.php.cn/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript">
    </script>
    <style type="text/css">
        html,
        body {
            margin: 0;
            padding: 0;
         }
         .demo {}
    </style>
    <body>
        <div class="demo">
            <section style="text-align: center;">
                <h1>title</h1>
                <p>2017-07-11</p>
            </section>
        </div>
    </body>
 </html>

尽管section元素在技术上是可以设计样式的,但是当有复杂的样式或脚本时,我们仍建议使用div元素。

类似于<li>元素,section元素是用来列举内容的。

因此在现实例子中,使用<section>元素的原因是结构化的列出博客的内容,代码如下:

<div class="blog">   
    <section class="post">   
        <h2 class="post-title">Blog Post Title</h2>   
        <p class="post-excerpt">Ice cream tart powder jelly-o.    
        Gummies chocolate cake ice cream cookie halvah tiramisu jelly-o.</p>   
    </section>   
    <section class="post">   
        <h2 class="post-title">Blog Post Title</h2>   
        <p class="post-excerpt">Ice cream tart powder jelly-o.    
        Gummies chocolate cake ice cream cookie halvah tiramisu jelly-o.</p>   
    </section>   
    <section class="post">   
        <h2 class="post-title">Blog Post Title</h2>   
        <p class="post-excerpt">Ice cream tart powder jelly-o.    
        Gummies chocolate cake ice cream cookie halvah tiramisu jelly-o.</p>   
    </section>   
</div>

这只是个例子,<section>元素也可以用作其他用途。

【元素有话说】

section:

hello,ladies and gentlemen,我是section。我参加的国际会议,是这么介绍我的,“The section element represents a generic section of a document or application. A section , in this context, is a thematic grouping of content, typically with a heading.” 我是带有语义的div,“Examples of sections would be chapters, the various tabbed pages in a tabbed dialog box, or the numbered sections of a thesis. A Web site’s home page could be split into sections for an introduction, news items, and contact information.”我出席的场景一般是有文章的章节、标签对话框中的标签页、或者论文中有编号的部分。一个网站的主页可以分成简介、新闻和联系信息等几部分。我不仅仅是一个普通的容器标签。当一个标签只是为了样式化或者方便脚本使用时,应该去找我的朋友 div 。一般来说,当元素内容明确地出现在文档大纲中时,我是很好的人选。通常会带有标题,<section><h1></h1><p></p></section>。我会用于对网站或者应用程序中页面上的内容进行分块。

【相关推荐】

HTML IMG标签的属性是有哪些?了解IMG标签的用法

HTML5中web是什么?web存储中的元素有哪些?

以上就是HTML5中的section标签是什么?HTML5中的section标签怎么居中?的详细内容,更多请关注其它相关文章!

  • HTML5中的section标签 HTML5中的section标签怎么居中
    • HTML5中的article标签是什么?HTML5中的article元素用在什么地方?
    • HTML5中footer标签的用法你知道吗?,HTML5中的footer标签是什么意思?