search
HomeWeb Front-endHTML TutorialSemantize your HTML tags and attributes

Semantize your HTML tags and attributes

Apr 05, 2017 pm 04:52 PM
htmlAttributesLabelSemantics

Another important aspect of separating structure and presentation is the use of semantic markup to structure document content. The presence of an XHTML element means that the portion of the marked content has a corresponding structural meaning, and there is no reason to use other markup. In other words, don't let CSS make one HTML element look like another HTML element, such as using

instead of a

tag heading.

The first is about the difference between semantics and default styles. The default style is the expression of some commonly used tags set by the browser. Personally, I think its main purpose is to let everyone intuitively understand markup and attributes. Purpose and function, it is obvious that the Hx series looks a lot like the title, because of the bold and larger font size. , are used to distinguish them from other words and play a role in emphasis. Lists and tables clearly tell you what they do.

Secondly, the most important benefit of semantic web pages is that they are friendly to search engines. With good structure and semantics, your web content will naturally be easily crawled by search engines, and you can save a lot of effort in promoting your website.

,

,

,

,

,
, are used as titles, in descending order of importance.

is the highest level. For example:
<h1>文档标题</h1>
<h2 id="次级标题">次级标题</h2>

Instead of using

Document Title

, or Document Title. Obviously search engines will not use the latter. Think he's the one in the title.

Paragraph mark, after knowing

as a paragraph, you will no longer use
to break lines, and there is no need for

to distinguish paragraphs from paragraphs. The text in

will wrap automatically, and the line wrapping effect is better than
. The gaps between paragraphs can also be controlled using CSS, making it easy and clear to distinguish paragraphs from each other. Using line-height can easily define the spacing between lines, and then define effects such as drop caps, which is perfect. For example:
<p>Admin10000.com 是WEB开发者学习交流的网站,这里提供大量实用的技术文档及相关资源下载,是网页设计、网络编程人员及其爱好者必备网站。</p>
<p>希望大家能在这里学到WEB开发知识,启发灵感,提高自己的WEB开发水平。</p>

    Unordered lists are so common that they are widely used by everyone,
    Ordered lists are also quite commonly used. In the process of web standardization,
    is also used more in navigation bars. Originally, the navigation bar was a list. This is completely correct, and when your browser does not support CSS, the navigation links are still very convenient. It works fine, but the aesthetics are a bit off. For example:

        
  • 项目一
  •     
  • 项目二
  •     
  • 项目三
<ol>
    <li>第一章</li>
    <li>第二章</li>
    <li>第三章</li>
</ol>

,
,

dl is "definition list". For example, this kind of list can be used for the explanations and definitions of words in the dictionary. For example:


Dog
A carnivorous mammal of the family Canidae.

    
上海滩
    
这部拍摄于1980年的《上海滩》堪称是香港电视史上最成功、最经典的剧集。     当年在香港播出以后,产生了巨大的轰动效应。
    
周润发
    
和所有伟大的影星一样,周润发印证了一个时代,一个香港电影的黄金时代。 风衣墨镜、冷血双枪、阳光微笑,都封存胶片之中,当我们回首寻望的时候,发哥已被刻为一个时代的坐标。

, cite, ,

Forums and blogs often use to mark short single-line quotes when quoting others. Web browsers will automatically recognize content between . Unfortunately, IE doesn't recognize it, and sometimes, can cause some accessibility issues. Because of this, some people recommend that you avoid using and manually insert citation tags. By adding a single line of reference content to a containing the appropriate class, you can style the reference with CSS, but this has no semantic meaning. You can read The Q tag (http://peintomark.org/archives/2002/05/04/the_q_tag) written by Mark Pilgrim for his views on dealing with related issues. For long quotes of one or more paragraphs, use

. CSS can be used to define styles for references. Note that a paragraph of article cannot be placed directly in
, the quoted content must also be included in an element, usually

. The cite attribute can be used with both and

to provide the source address of the quoted content. It should be noted that if you use instead of tag to quote content, then you cannot use the cite attribute. For example:

<cite>Designing with Web Standards</cite> is an excellent book by Jeffrey Zeldman.
<p> <cite>孔子</cite>曰:<q>学而不思则罔,思而不学则殆</q>.</p>
<p>The W3C says that <q struct>The presentation of phrase elements
depends on the user agent.</q>.</p>
<blockquote>
    <p>“我们大部分人都有深刻体验,每当主流浏览器版本的升级,我们刚建立的网站就可能变得过时,我们就需要升级或者重新建造一遍网站。例如1996-1999年典型的"浏览器大战",为了兼容 Netscape 和 IE,网站不得不为这两种浏览器写不同的代码。同样的,每当新的网络技术和交互设备的出现,我们也需要制作一个新版本来支持这种新技术或新设备,例如支持手机上网的 WAP 技术。类似的问题举不胜举:网站代码臃肿、繁杂浪费了我们大量的带宽;针对某种浏览器的 DHTML 特效,屏蔽了部分潜在的客户;不易用的代码,残障人士无法浏览网站等等。这是一种恶性循环,是一种巨大的浪费。”</p>
</blockquote>

是用作强调的,是用作重点强调的。 大部分浏览器用斜体显示强调的内容,用粗体来显示重点强调的内容,然而,这是没有必要的,如果是为了确定强调内容的显示方式,最好的方法就是使用CSS来定义他们的表现。当你想要的只是视觉上的效果时,就不要使用强调了。而且如果你想要强调但是还觉得粗体或者斜体不视觉效果没那么好,特别是斜体对于中文来说,那么你完全可以定义一些其他的比较醒目的样式达到强调的效果。例如:

<p><em>强调</em> 的文本通常用斜体显示,
然而,<strong>特别强调</strong> 的文本通常以粗体显示。</p>

、标签为表格头部,标签为表格主体内容,标签为表格尾部。
其中还可以使用scope 可用于取代headers属性,标记含有表头信息的单元格,其中各数值的内容如下:
 row 指示当前单元格,为包含当前单元格的行提供相关的表头信息。
 col 指示当前单元格,为根据当前单元格指定的列提供相应的表头信息。
 rowgroup 指示当前单元格,为包含当前单元格的其余行组提供相关的表头信息。
 colgroup 指示当前单元格,为根据当前单元格指定的其余列组提供相应的表头信息。
abbr 用于定义表头单元格中的缩写名,如果没有定义该属性,则将默认单元格内容为节略形式。
例如:
、、 summary

XHTML中的表格不应用来布局。然而如果是为了标记列表的数据,就应该使用表格了。

为表格标题,属性summar为摘要,
标签为首部说明,
                                                                                                                                     
Table 1: Power Mac G5 tech specs 
ConfigurationsDual 1.8GHzDual 2GHzDual 2.5GHz
ModelM9454LL/AM9455LL/AM9457LL/A
G5 ProcessorDual 1.8GHz PowerPC G5Dual 2GHz PowerPC G5Dual 2.5GHz PowerPC G5
Frontside bus900MHz per processor1GHz per processor1.25GHz per processor
Level2 Cache512K per processor512K per processor512K per processor

<p><dfn>Internet Explorer</dfn> is the most popular browser used underwater.</p>

 

,

知道del,就不要再用做删除线了,用del显然更具有语义化。而且del还带有cite和datetime来表明删除的原因以及删除的时间。ins是表示插入,也有这样的属性。例如:

<p>It really was <ins>very</ins> good.</p>

表示是计算机代码。而默认样式为打字体。技术论坛和blog中经常遇到。例如:

标签是表示web页面上的简称,标签为取首字母缩写。(注:这里把简称和缩写分开而论,简称范围比缩写大,取首字母的缩写用标签)Windows的IE6.0以下的浏览器暂不支持标签。 在IE里,你可以应用CSS给但是不能应用给标签,IE会为标签的title属性显示提示,但是会忽略标签。
解决方法见: http://www.w3cn.org/article/translate/2005/115.html
例如:

<abbr>CSS</abbr>
<acronym>CSS</acronym> >

alt属性和title属性

title属性用来为元素提供额外说明信息title属性可以用在除了base,basefont,head,html,meta,param,script和title之外的所有标签。但是并不是必须的。
alt属性为不能显示图像、窗体或applets的用户代理(UA),指定替换文字。替换文字的语言由lang属性指定。
 

<img  src="/static/imghwm/default1.png" data-src="/img/common/logo.gif" class="lazy" alt="Semantize your HTML tags and attributes" >
<a>js获取单选按钮的数据</a>

The above is the detailed content of Semantize your HTML tags and attributes. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML vs. CSS and JavaScript: Comparing Web TechnologiesHTML vs. CSS and JavaScript: Comparing Web TechnologiesApr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function