<!doctype html> <htmllang="en"> <head> <metacharset="utf-8"> <title>Formatting a biography</title> <linkrel="stylesheet"href="styles.css"> </head> <body> <h1>Jane Doe</h1> <divclass="job-title">Web Developer</div> <p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean.</p> <p>A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. </p> <h2>Contact information</h2> <ul> <li>Email: <ahref="mailto:jane@example.com">jane@example.com</a> </li> <li>Web: <ahref="http://example.com">http://example.com</a> </li> <li>Tel: 123 45678</li> </ul> </body> </html>
<p>I am a paragraph. A short one.</p> <ul> <li>Item One</li> <li>Item Two</li> <li>Item Three</li> </ul> <p>I am another paragraph. Some of the <spanclass="block">words</span> have been wrapped in a <span>span element</span>.</p>
p, ul { border: 2px solid rebeccapurple; } span, li { border: 2px solid blue; } ul { display: inline-flex; list-style: none; padding: 0; } .inline { display: inline; }
1 2 3 4 5 6 7 8 9 10 11 12
<p> I am a paragraph. Some of the <span>words</span> have been wrapped in a <span>span element</span>. </p> <ul> <li>Item One</li> <li>Item Two</li> <li>Item Three</li> </ul> <pclass="inline">I am a paragraph. A short one.</p> <pclass="inline">I am another paragraph. Also a short one.</p>
指向网站各个主要区段的超链接。通常用菜单按钮、链接或标签页表示。类似于标题栏,导航栏通常应在所有网页之间保持一致,否则会让用户感到疑惑,甚至无所适从。许多 web 设计人员认为导航栏是标题栏的一部分,而不是独立的组件,但这并非绝对;还有人认为,两者独立可以提供更好的 无障碍访问特性,因为屏幕阅读器可以更清晰地分辨二者。
<metaname="description"content="The MDN Learning Area aims to provide complete beginners to the Web with all they need to know to get started with developing web sites and applications.">
还有的属性是用来辨识当前元素的。假如我开了一个网络小说网站,现在有一大堆<p>元素,其中有的是写的文章的自然段,有的是网站的一些其他文本。现在我要给所有网文自然段加上好看的Noto Sans CJK字体(当然这需要CSS),怎么让浏览器知道哪些文本应该改字体,哪些文本不需要呢? 我们给这些<p>元素标记一下,有的标记成“自然段”,有的不标记,浏览器就知道标记了的<p>元素需要改字体。这里就要用到HTML的一个属性——class。class就是“类”的意思。HTML的每种元素都可以带class属性。回到我们之前说的<p>元素:
对于<em>、<cite>和<i>,默认情况下,它们的视觉效果是一样的。但语义是不同的。 <em> 标签表示其内容的着重强调,而 <i> 标签表示从正常散文中区分出的文本,例如外来词,虚构人物的思想,或者当文本指的是一个词语的定义,而不是其语义含义。(作品的标题,例如书籍或电影的名字,应该使用 <cite>。) 这意味着,正确使用哪一个取决于具体的场景。两者都不是纯粹为了装饰的目的,那是CSS样式所做的。 一个 <em> 的例子可能是:”Just do it already!”,或:”We had to do something about it”。人或软件在阅读文本时,会对斜体字的发音使用重读强调。 一个 <i> 的例子可能是:”The Queen Mary sailed last night”。在这里,没有对 “Queen Mary” 这个词添加强调或重要性。它只是表明,谈论的对象不是一个名叫玛丽的女王,而是一艘名字叫玛丽的船。另一个 <i> 的例子可能是:”The word the is an article”。