html怎么设置文字居中对齐
时间:2022-02-23 17:34
html设置文字居中对齐的方法是,给段落文字添加text-align属性,并且设置属性值为center即可,例如【h1 {text-align:center}】。text-align属性指定了元素文本的水平对齐方式。 本文操作环境:windows10系统、html 5、thinkpad t480电脑。 要把文本设置成居中对齐,只需要借助于text-align属性即可。也许有些刚刚接触编程的小伙伴还不太了解text-algin属性,不明白它有什么用处,下面我就来为大家简单介绍下该属性。 text-align属性指定元素文本的水平对齐方式。 常用属性值如下: left 把文本排列到左边。默认值:由浏览器决定。 right 把文本排列到右边。 center 把文本排列到中间。 justify 实现两端对齐文本效果。 inherit 规定应该从父元素继承 text-align 属性的值。 代码演示: 运行结果如下显示: 相关视频分享:html视频教程 以上就是html怎么设置文字居中对齐的详细内容,更多请关注gxlsystem.com其它相关文章!<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>gxlsystem.com(gxlsystem.com)</title>
<style>
h1 {text-align:center}
h2 {text-align:left}
h3 {text-align:right}
</style>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
</body>
</html>