HTML学习(2)标签

HTML标签

1、标题标签,通过<h1>-- <h6>来定义

<h1>Head1</h1>
<h2>Head2</h2>
<h3>Head3</h3>

2、段落标签,通过<p> 来定义

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

3、链接标签,通过<a>来定义

<a href="http://www.w3school.com.cn">This is a link</a>

在href属性指定链接地址

4、图像链接,通过<img>标签定义

<img src="w3school.jpg" width="104" height="142" />

5、<body>元素,定义了HTML文档的主体

<body>
<p>This is my first paragraph.</p>
</body>

6、<html>元素,定义了整个HTML文档

<html>

<body>
<p>This is my first paragraph.</p>
</body>

</html>

7、<br> 标签定义换行

8、HTML 标签对大小写不敏感:<P> 等同于 <p>。许多网站都使用大写的 HTML 标签。


HTML 元素

1、HTML元素指的是从标签开始到标签结束的所有代码。

以下面这行代码为例子,开始标签是<p>,结束标签是</p>,元素内容是:This is my first paragraph.

<p>This is my first paragraph.</p>

2、元素可以嵌套,比如下面这段代码包含3个HTML元素

<html>

<body>
<p>This is my first paragraph.</p>
</body>

</html>

HTML元素属性

1、链接地址由属性href定义

<a href="http://www.w3school.com.cn">This is a link</a>

2、标题的对齐方式由align属性定义

<html>

<body>

<h1 align="center">This is heading 1</h1>

<p>Heading displayed in Center</p>

</body>
</html>

3、背景颜色由bgcolor定义

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
</head>

<body bgcolor="yellow">
<h2>Bgcolor is changed!</h2>
</body>

</html>

注:属性值加引号,属性推荐用小写。


标签列表

1、基础标签

2、更多标签请看文档:

http://www.w3school.com.cn/tags/html_ref_byfunc.asp

猜你喜欢

转载自blog.csdn.net/liying15/article/details/86304921
今日推荐