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 提示框)
主站蜘蛛池模板: 镀锌方管,无缝方管,伸缩套管,方矩管_山东重鑫致胜金属制品有限公司 | BHK汞灯-百科|上海熙浩实业有限公司 | 过跨车_过跨电瓶车_过跨转运车_横移电动平车_厂区转运车_无轨转运车 | 拖链电缆_柔性电缆_伺服电缆_坦克链电缆-深圳市顺电工业电缆有限公司 | 精密五金冲压件_深圳五金冲压厂_钣金加工厂_五金模具加工-诚瑞丰科技股份有限公司 | 脑钠肽-白介素4|白介素8试剂盒-研域(上海)化学试剂有限公司 | 新疆十佳旅行社_新疆旅游报价_新疆自驾跟团游-新疆中西部国际旅行社 | 上海办公室装修公司_办公室设计_直营办公装修-羚志悦装 | 水篦子|雨篦子|镀锌格栅雨水篦子|不锈钢排水篦子|地下车库水箅子—安平县云航丝网制品厂 | 二手色谱仪器,十万分之一分析天平,蒸发光检测器,电位滴定仪-湖北捷岛科学仪器有限公司 | 酵素生产厂家_酵素OEM_酵素加盟_酵素ODM_酵素原料厂家_厦门益力康 | 手表腕表维修保养鉴定售后服务中心网点 - 名表维修保养 | 聚合氯化铝-碱式氯化铝-聚合硫酸铁-聚氯化铝铁生产厂家多少钱一吨-聚丙烯酰胺价格_河南浩博净水材料有限公司 | 高尔夫球杆_高尔夫果岭_高尔夫用品-深圳市新高品体育用品有限公司 | 透平油真空滤油机-变压器油板框滤油机-滤油车-华之源过滤设备 | 电缆隧道在线监测-智慧配电站房-升压站在线监测-江苏久创电气科技有限公司 | 淋巴细胞分离液_口腔医疗器材-精欣华医疗器械(无锡)有限公司 | 黑龙江「京科脑康」医院-哈尔滨失眠医院_哈尔滨治疗抑郁症医院_哈尔滨精神心理医院 | 卓能JOINTLEAN端子连接器厂家-专业提供PCB接线端子|轨道式端子|重载连接器|欧式连接器等电气连接产品和服务 | 捷码低代码平台 - 3D数字孪生_大数据可视化开发平台「免费体验」 | 伟秀电气有限公司-10kv高低压开关柜-高低压配电柜-中置柜-充气柜-欧式箱变-高压真空断路器厂家 | 外贸网站建设-外贸网站设计制作开发公司-外贸独立站建设【企术】 | 儿童乐园|游乐场|淘气堡招商加盟|室内儿童游乐园配套设备|生产厂家|开心哈乐儿童乐园 | 刮板输送机,粉尘加湿搅拌机,螺旋输送机,布袋除尘器 | 米顿罗计量泵(科普)——韬铭机械 | 一路商机网-品牌招商加盟优选平台-加盟店排行榜平台 | 上海刑事律师|刑事辩护律师|专业刑事犯罪辩护律师免费咨询-[尤辰荣]金牌上海刑事律师团队 | 制氮设备_PSA制氮机_激光切割制氮机_氮气机生产厂家-苏州西斯气体设备有限公司 | 电动打包机_气动打包机_钢带捆扎机_废纸打包机_手动捆扎机 | 飞飞影视_热门电影在线观看_影视大全| 酒糟烘干机-豆渣烘干机-薯渣烘干机-糟渣烘干设备厂家-焦作市真节能环保设备科技有限公司 | 炉门刀边腹板,焦化设备配件,焦化焦炉设备_沧州瑞创机械制造有限公司 | 高防护蠕动泵-多通道灌装系统-高防护蠕动泵-www.bjhuiyufluid.com慧宇伟业(北京)流体设备有限公司 | 气动隔膜泵-电动隔膜泵-循环热水泵-液下排污/螺杆/管道/化工泵「厂家」浙江绿邦 | 小型气象站_便携式自动气象站_校园气象站-竞道气象设备网 | 气力输送设备_料封泵_仓泵_散装机_气化板_压力释放阀-河南锐驰机械设备有限公司 | 电机保护器-电动机综合保护器-浙江开民 | 真空泵厂家_真空泵机组_水环泵_旋片泵_罗茨泵_耐腐蚀防爆_中德制泵 | 杭州中央空调维修_冷却塔/新风机柜/热水器/锅炉除垢清洗_除垢剂_风机盘管_冷凝器清洗-杭州亿诺能源有限公司 | 沟盖板_复合沟盖板厂_电力盖板_树脂雨水篦子-淄博拜斯特 | 智能交通网_智能交通系统_ITS_交通监控_卫星导航_智能交通行业 |