pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

HTML5 最佳實踐;部分/標題/旁白/文章元素

HTML5 best practices; section/header/aside/article elements(HTML5 最佳實踐;部分/標題/旁白/文章元素)
本文介紹了HTML5 最佳實踐;部分/標題/旁白/文章元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

網絡上有足夠的關于 HTML5 的信息(以及在 stackoverflow 上),但現在我對最佳實踐"感到好奇.像section/headers/article這樣的標簽是新的,每個人對何時/何地應該使用這些標簽有不同的看法.那么你們覺得下面的布局和代碼怎么樣?

 1 <!doctype html>2 <頭>3 <title>網站</title>4 </頭>56<身體>7<部分>8 <標題>9 <div id="logo"></div>10 <div id="語言"></div>11 </標題>1213 <導航>14 <ul>15 <li>菜單 1</li>16 <li>菜單 2</li>17 <li>菜單 3</li>18 <li>菜單 4</li>19 <li>菜單 5</li>20 </ul>21 </導航>2223 

第 7 行.section 圍繞整個網站?還是只有一個div?

第 8 行.每個 section 都以 header 開頭?

第 23 行.這個 div 對嗎?還是必須是 section?

第 24 行.用 div 分割左/右列.

第 25 行.article 標簽的正確位置?

第 26 行.是否需要將 h1-tag 放在 header-tag 中?

第 43 行.內容與主要文章無關,所以我決定這是一個 section 而不是 aside.

第 44 行.沒有 header

的 H2

第 53 行.section 沒有 header

第 63 行.包含所有(非相關)新聞項目的 Div

第 64 行.header 與 h2

第 65 行.嗯,div 還是 section?或者刪除這個 div 并且只使用 article-tag

第 105 行.頁腳 :-)

解決方案

其實,在頁眉/頁腳方面,您是完全正確的.以下是關于如何/應該使用每個主要 HTML5 標簽的一些基本信息(我建議閱讀底部鏈接的完整源代碼):

<塊引用>

部分 - 用于將與主題相關的內容組合在一起.聽起來像一個 div 元素,但它不是.div 沒有語義.在用部分元素替換所有 div 之前,請始終問自己:所有內容都相關嗎?"

aside – 用于相關內容.僅僅因為某些內容出現在主要內容的左側或右側并不足以成為使用 side 元素的理由.問問自己是否可以在不降低主要內容含義的情況下刪除旁白中的內容.Pullquotes 是切向相關內容的一個示例.

header – 標題元素與普遍接受的標題(或標頭)用法之間存在關鍵區別.一頁中通常只有一個標題或標頭".在 HTML5 中,您可以擁有任意數量的內容.該規范將其定義為一組介紹性或導航輔助工具".您可以在網站的任何部分使用標題.事實上,您可能應該在大多數部分中使用標題.該規范將 section 元素描述為內容的主題分組,通常帶有標題."

nav - 用于主要導航信息.組合在一起的一組鏈接不足以成為使用 nav 元素的理由.另一方面,站點范圍的導航屬于 nav 元素.

footer – 聽起來像是對位置的描述,但實際上不是.頁腳元素包含有關其包含元素的信息:作者、版權、相關內容的鏈接等.雖然我們通常有一個頁腳用于整個文檔,但 HTML5 允許我們在部分內也有頁腳.

來源:https://clzd.me/html5-section-aside-header-nav-footer-elements-not-as-obvious-as-they-sound/

另外,這里有一個關于article的描述,在上面的源代碼中沒有找到:

<塊引用>

article – 用于指定獨立、自包含內容的元素.一篇文章本身就應該有意義.在用文章元素替換所有 div 之前,請始終問自己:是否可以獨立于網站的其他部分閱讀它?"

There is enough information about HTML5 on the web (and also on stackoverflow), but now I'm curious about the "best practices". Tags like section/headers/article are new, and everyone has different opinions about when/where you should use these tags. So what do you guys think of the following layout and code?

  1  <!doctype html>
  2      <head>
  3          <title>Website</title>
  4      </head>
  5  
  6      <body>
  7          <section>
  8              <header>
  9                  <div id="logo"></div>
 10                  <div id="language"></div>
 11              </header>
 12  
 13              <nav>
 14                  <ul>
 15                      <li>menu 1</li>
 16                      <li>menu 2</li>
 17                      <li>menu 3</li>
 18                      <li>menu 4</li>
 19                      <li>menu 5</li>
 20                  </ul>
 21              </nav>
 22  
 23              <div id="main">
 24                  <div id="main-left">
 25                      <article>
 26                          <header><h1>This is a title</h1></header>
 27  
 28                          <p>Lorem ipsum dolor sit amet, consectetur
 29                          adipiscing elit. Quisque semper, leo eget</p>
 30  
 31                          <p>Lorem ipsum dolor sit amet, consectetur
 32                          adipiscing elit. Quisque semper, leo eget</p>
 33  
 34                          <p>Lorem ipsum dolor sit amet, consectetur
 35                          adipiscing elit. Quisque semper, leo eget</p>
 36  
 37                          <p>Lorem ipsum dolor sit amet, consectetur
 38                          adipiscing elit. Quisque semper, leo eget</p>
 39                      </article>
 40                  </div>
 41  
 42                  <div id="main-right">
 43                      <section id="main-right-hot">
 44                          <h2>Hot items</h2>
 45                          <ul>
 46                              <li>Lorem ipsum</li>
 47                              <li>dolor sit</li>
 48                              <li>...</li>
 49                          </ul>
 50                      </section>
 51  
 52                      <section id="main-right-new">
 53                          <h2>New items</h2>
 54                          <ul>
 55                              <li>Lorem ipsum</li>
 56                              <li>dolor sit</li>
 57                              <li>...</li>
 58                          </ul>
 59                      </section>
 60                  </div>
 61              </div>
 62  
 63              <div id="news-items">
 64                  <header><h2>The latest news</h2></header>
 65  
 66                  <div id="item_1">
 67                      <article>
 68                          <header>
 69                              <img src="#" title="titel artikel" />
 70                              <h3>Lorem ipsum .....</h3>
 71                          </header>
 72                          <p>Lorem ipsum dolor sit amet,
 73                          adipiscing elit. Quisque semper, </p>
 74                          <a href="#">Read more</a>
 75                      </article>
 76                  </div>
 77  
 78  
 79                  <div id="item_2">
 80                      <article>
 81                          <header>
 82                              <img src="#" title="titel artikel" />
 83                              <h3>Lorem ipsum .....</h3>
 84                          </header>
 85                          <p>Lorem ipsum dolor sit amet,
 86                          adipiscing elit. Quisque semper, </p>
 87                          <a href="#">Read more</a>
 88                      </article>
 89                  </div>
 90  
 91  
 92                  <div id="item_3">
 93                      <article>
 94                          <header>
 95                              <img src="#" title="titel artikel" />
 96                              <h3>Lorem ipsum .....</h3>
 97                          </header>
 98                          <p>Lorem ipsum dolor sit amet,
 99                          adipiscing elit. Quisque semper, </p>
100                          <a href="#">Read more</a>
101                      </article>
102                  </div>
103              </div>
104  
105              <footer>
106                  <ul>
107                      <li>menu 1</li>
108                      <li>menu 2</li>
109                      <li>menu 3</li>
110                      <li>menu 4</li>
111                      <li>menu 5</li>
112                  </ul>
113              </footer>
114          </section>
115      </body>
116  </html>

line 7. section around the whole website? Or only a div?

line 8. Each section start with a header?

line 23. Is this div right? or must this be a section?

line 24. Split left/right column with a div.

line 25. Right place for the article tag?

line 26. Is it required to put your h1-tag in the header-tag?

line 43. The content is not related to the main article, so I decided this is a section and not a aside.

line 44. H2 without header

line 53. section without header

line 63. Div with all (non-related) news items

line 64. header with h2

line 65. Hmm, div or section? Or remove this div and only use the article-tag

line 105. Footer :-)

解決方案

Actually, you are quite right when it comes to header/footer. Here is some basic information on how each of the major HTML5 tags can/should be used (I suggest reading the full source linked at the bottom):

section – Used for grouping together thematically-related content. Sounds like a div element, but it’s not. The div has no semantic meaning. Before replacing all your div’s with section elements, always ask yourself: "Is all of the content related?"

aside – Used for tangentially related content. Just because some content appears to the left or right of the main content isn’t enough reason to use the aside element. Ask yourself if the content within the aside can be removed without reducing the meaning of the main content. Pullquotes are an example of tangentially related content.

header – There is a crucial difference between the header element and the general accepted usage of header (or masthead). There’s usually only one header or ‘masthead’ in a page. In HTML5 you can have as many as you want. The spec defines it as "a group of introductory or navigational aids". You can use a header in any section on your site. In fact, you probably should use a header within most of your sections. The spec describes the section element as "a thematic grouping of content, typically with a heading."

nav – Intended for major navigation information. A group of links grouped together isn’t enough reason to use the nav element. Site-wide navigation, on the other hand belongs in a nav element.

footer – Sounds like its a description of the position, but its not. Footer elements contain informations about its containing element: who wrote it, copyright, links to related content, etc. Whereas we usually have one footer for an entire document, HTML5 allows us to also have footer within sections.

Source: https://clzd.me/html5-section-aside-header-nav-footer-elements-not-as-obvious-as-they-sound/

Additionally, here's a description on article, not found in the source above:

article – Used for element that specifies independent, self-contained content. An article should make sense on its own. Before replacing all your div’s with article elements, always ask yourself: "Is it possible to read it independently from the rest of the web site?"

這篇關于HTML5 最佳實踐;部分/標題/旁白/文章元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
Updating table with Dynatable plugin(使用 Dynatable 插件更新表)
jQuery tooltip add line break(jQuery 工具提示添加換行符)
Why is the lightbox jQuery plugin not working for me?(為什么燈箱 jQuery 插件對我不起作用?)
Alternative to Javascript prompt box for younger users(為年輕用戶替代 Javascript 提示框)
主站蜘蛛池模板: 点胶机_点胶阀_自动点胶机_智能点胶机_喷胶机_点胶机厂家【欧力克斯】 | 流量卡中心-流量卡套餐查询系统_移动电信联通流量卡套餐大全 | 北京宣传片拍摄_产品宣传片拍摄_宣传片制作公司-现像传媒 | 专业广州网站建设,微信小程序开发,一物一码和NFC应用开发、物联网、外贸商城、定制系统和APP开发【致茂网络】 | 沈阳缠绕膜价格_沈阳拉伸膜厂家_沈阳缠绕膜厂家直销 | 二手注塑机回收_旧注塑机回收_二手注塑机买卖 - 大鑫二手注塑机 二手光谱仪维修-德国OBLF光谱仪|进口斯派克光谱仪-热电ARL光谱仪-意大利GNR光谱仪-永晖检测 | 合肥白癜风医院_合肥治疗白癜风医院_合肥看白癜风医院哪家好_合肥华研白癜风医院 | 右手官网|右手工业设计|外观设计公司|工业设计公司|产品创新设计|医疗产品结构设计|EMC产品结构设计 | 大白菜官网,大白菜winpe,大白菜U盘装系统, u盘启动盘制作工具 | 刺绳_刀片刺网_刺丝滚笼_不锈钢刺绳生产厂家_安平县浩荣金属丝网制品有限公司-安平县浩荣金属丝网制品有限公司 | 螺旋绞龙叶片,螺旋输送机厂家,山东螺旋输送机-淄博长江机械制造有限公司 | 全自动在线分板机_铣刀式在线分板机_曲线分板机_PCB分板机-东莞市亿协自动化设备有限公司 | COD分析仪|氨氮分析仪|总磷分析仪|总氮分析仪-圣湖Greatlake | 刮板输送机,粉尘加湿搅拌机,螺旋输送机,布袋除尘器 | 山东商品混凝土搅拌楼-环保型搅拌站-拌合站-分体仓-搅拌机厂家-天宇 | LED显示屏_LED屏方案设计精准报价专业安装丨四川诺显科技 | Duoguan 夺冠集团 | 中细软知识产权_专业知识产权解决方案提供商| 中国产业发展研究网 - 提供行业研究报告 可行性研究报告 投资咨询 市场调研服务 | 湖南长沙商标注册专利申请,长沙公司注册代理记账首选美创! | 高温热泵烘干机,高温烘干热泵,热水设备机组_正旭热泵 | 施工围挡-施工PVC围挡-工程围挡-深圳市旭东钢构技术开发有限公司 | 福尔卡(北京)新型材料技术股份有限公司| 稳尚教育加盟-打造高考志愿填报平台_新高考志愿填报加盟_学业生涯规划加盟 | H型钢切割机,相贯线切割机,数控钻床,数控平面钻,钢结构设备,槽钢切割机,角钢切割机,翻转机,拼焊矫一体机 | 膜结构车棚|上海膜结构车棚|上海车棚厂家|上海膜结构公司 | 量子管通环-自清洗过滤器-全自动反冲洗过滤器-北京罗伦过滤技术集团有限公司 | 管理会计网-PCMA初级管理会计,中级管理会计考试网站 | 生物风-销售载体,基因,质粒,ATCC细胞,ATCC菌株等,欢迎购买-百风生物 | 全自动实验室洗瓶机,移液管|培养皿|进样瓶清洗机,清洗剂-广州摩特伟希尔机械设备有限责任公司 | 高温链条油|高温润滑脂|轴承润滑脂|机器人保养用油|干膜润滑剂-东莞卓越化学 | 开平机_纵剪机厂家_开平机生产厂家|诚信互赢-泰安瑞烨精工机械制造有限公司 | 无线联网门锁|校园联网门锁|学校智能门锁|公租房智能门锁|保障房管理系统-KEENZY中科易安 | 玻璃钢格栅盖板|玻璃钢盖板|玻璃钢格栅板|树篦子-长沙川皖玻璃钢制品有限公司 | 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 食品质构分析仪-氧化诱导分析仪-瞬态法导热系数仪|热冰百科 | 河南正规膏药生产厂家-膏药贴牌-膏药代加工-修康药业集团官网 | 氧化锆纤维_1800度高温退火炉_1800度高温烧结炉-南京理工宇龙新材料股份有限公司 | 辊道窑炉,辊道窑炉厂家-山东艾希尔| HEYL硬度计量泵-荧光法在线溶解氧仪-净时测控技术(上海)有限公司 | 环压强度试验机-拉链拉力试验机-上海倾技仪器仪表科技有限公司 |