为什么使用 HTML5 标签?

2023-07-31前端开发问题
3

本文介绍了为什么使用 HTML5 标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

可能重复:
是像 <section> 这样的新 HTML5 元素吗?和<文章>没意义?

我最终决定转向使用 HTML5 设计网站.我有一个关于新标签的问题.

I have decided to, finally, make the move to designing websites in HTML5. I have one question about the new tags.

有新的标签,例如;页眉、页脚、导航栏等.为什么这些标签比使用 DIV ID 的旧方法更受欢迎(例如 <div id="header">).我可以理解为什么这会使事情变得更简单,但是让一些使用 HTML5 的标签和一些使用旧方法的标签不会更令人困惑吗?我个人认为使用 all 或 none 比混合使用更合乎逻辑.

There are new tags such as; header, footer, navbar, etc.. Why are these tags preferred over the older method of using DIV ID's (eg. <div id="header">). I can see why this would make things simpler but wouldn't it be more confusing to have some tags that use HTML5 and some tags that use the older method? I, personally, find it more logical to use all or none, rather than a mixture.

如果我完全没有抓住重点,请告诉我.

If I'm missing the point entirely please let me know.

推荐答案

这不是非此即彼的情况.HTML5 仍然有 <div>.它仍然有 <span>s.新标签可以为您提供更多表达自由并标准化常见元素.例如,大多数页面都有导航栏,但到目前为止还没有关于如何标记的标准.如果它们被清楚地标记为 <nav>,程序就可以开始有效地使用这些信息.搜索引擎可以忽略或解析它们,而辅助技术可以帮助用户浏览网站.

It's not an either-or situation. HTML5 still has <div>s. It still has <span>s. The new tags are there to give you more expressive freedom and to standardize common elements. For instance, most pages have navigation bars, yet so far there was no standard for how those were marked up. If they're clearly marked up as <nav>, programs can start to use this information productively. Search engines can ignore or parse them and assistive technology can help the user navigate around the site.

它还使您可以更轻松地处理代码.<nav><div class="main nav foobar baz"> 更容易被发现.

It also makes it easier for you to work with your code. <nav> is so much easier to spot than <div class="main nav foobar baz">.

新标签是添加,而不是替换旧标签的全新集合.

The new tags are an addition, not an entirely new set replacing the old tags.

这篇关于为什么使用 HTML5 标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

jQuery怎么动态向页面添加代码?
append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href...
2024-10-18 前端开发问题
125

“数组中的每个孩子都应该有一个唯一的 key prop"仅在第一次呈现页面时
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)...
2024-04-20 前端开发问题
5

CoffeeScript 总是以匿名函数返回
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)...
2024-04-20 前端开发问题
13

getFullYear 在一年的第一天返回前一年
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)...
2024-04-20 前端开发问题
6