如何使<h2>中的文本出现在中心</h2>

时间:2013-10-26 09:00:46

标签: html css

我正在使用<h2>标记。标题显示为左对齐。如何让文字显示在<h2>的中心?

3 个答案:

答案 0 :(得分:2)

使用CSS text-align属性:

text-align: center;

此属性的其他值包括leftrightjustify

答案 1 :(得分:1)

试试这个:

h2{
   width: 100%;
   text-align: center;
}

答案 2 :(得分:0)

在Css中,将text-align:center用于特定代码<h2>

示例

<强> HTML

<h2 class="aligncenter">Welcome</h2>

<强> CSS

.aligncenter{
    text-align: center;
}