什么是语义标记,为什么要使用它? [英] What is semantic markup, and why would I want to use that?

查看:357
本文介绍了什么是语义标记,为什么要使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像说的那样.

解决方案

使用语义标记意味着您在页面中使用的(X)HTML代码包含描述其目的的元数据-例如,<h2>包含员工的姓名可能会标记为class="employee-name".最初,有些人希望搜索引擎会使用此信息,但是随着网络的发展,语义标记已主要用于为CSS提供挂钩.

使用CSS和语义标记,您可以将页面的视觉设计与标记分开.这样可以节省带宽,因为设计只需要下载一次,而设计更容易修改,因为它不会混入标记中.


另一点是,所使用的元素应与其中包含的数据具有逻辑关系.例如,表应该用于表格数据,<p>应该用于文本段落,<ul>应该用于无序列表,等等.这与早期的Web设计相反,早期的Web设计经常将表用于所有内容. /p>

Like it says.

解决方案

Using semantic markup means that the (X)HTML code you use in a page contains metadata describing its purpose -- for example, an <h2> that contains an employee's name might be marked class="employee-name". Originally there were some people that hoped search engines would use this information, but as the web has evolved semantic markup has been mostly used for providing hooks for CSS.

With CSS and semantic markup, you can keep the visual design of the page separate from the markup. This results in bandwidth savings, because the design only has to be downloaded once, and easier modification of the design because it's not mixed in to the markup.


Another point is that the elements used should have a logical relationship to the data contained within them. For example, tables should be used for tabular data, <p> should be used for textual paragraphs, <ul> should be used for unordered lists, etc. This is in contrast to early web designs, which often used tables for everything.

这篇关于什么是语义标记,为什么要使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆