一、【概念】
text-align作为HTML元素属性,在CSS中其属性用作控制文本水平方向的对齐方式。
二、【使用】
1.属性值
- left:左对齐
- right:右对齐
- center:居中对齐
三、【示例】
1.left (程序示范)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- title>网页标题</title> -->
<style type="text/css">
h1{
text-align: left;
/*text-align属性用于设置元素内文本内容的水平对齐方式
left:左对齐(默认值)
right:右对齐
center:居中对齐
*/
}
</style>
</head>
<body>
<h1>阅读者都很帅</h1>
</body>
</html>
2.right(程序示范)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- title>网页标题</title> -->
<style type="text/css">
h1{
text-align: right;
/*text-align属性用于设置元素内文本内容的水平对齐方式
left:左对齐(默认值)
right:右对齐
center:居中对齐
*/
}
</style>
</head>
<body>
<h1>阅读者都很帅</h1>
</body>
</html>
3.center(程序示范)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- title>网页标题</title> -->
<style type="text/css">
h1{
text-align: center;
/*text-align属性用于设置元素内文本内容的水平对齐方式
left:左对齐(默认值)
right:右对齐
center:居中对齐
*/
}
</style>
</head>
<body>
<h1>阅读者都很帅</h1>
</body>
</html>