<html>
<body>
<h1>Hello World!</h1>
<p> Hello World</p>
</body>
</html>
例子解释
- <html> 与 </html> 之间的文本描述网页
- <body> 与 </body> 之间的文本是可见的页面内容
- <h1> 与 </h1> 之间的文本被显示为标题
- <p> 与 </p> 之间的文本被显示为段落
HTML 标题(Heading)是通过 <h1> - <h6> 等标签进行定义的。
实例
<html> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> <h3>This is heading 3</h3> <h4>This is heading 4</h4> <h5>This is heading 5</h5> <h6>This is heading 6</h6> <p>请仅仅把标题标签用于标题文本。不要仅仅为了产生粗体文本而使用它们。请使用其它标签或 CSS 代替。</p> </body> </html>
HTML 段落
HTML 段落是通过 <p> 标签进行定义的。
<html>
<body>
<p>这是段落。</p>
<p>这是段落。</p>
<p>这是段落。</p>
<p>段落元素由 p 标签定义。</p>
</body>
</html>
HTML 链接
HTML 链接是通过 <a> 标签进行定义的。
注释: 在 href 属性中指定链接的地址。
<html>
<body>
<a href="http://www.csdn.com">This is a link</a>
</body>
</html>
HTML 水平线
<hr /> 标签在 HTML 页面中创建水平线。
hr 元素可用于分隔内容。
实例
<p>This is a paragraph</p> <hr /> <p>This is a paragraph</p> <hr /> <p>This is a paragraph</p>
HTML 图像
HTML 图像是通过 <img> 标签进行定义的。
<html>
<body>
<img src="/i/eg_w3school.gif" width="300" height="120" />
</body>
</html>
注释:
图像的名称和尺寸是以属性的形式提供的。