Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make heading center align

How to center <h3> in the following code?

h1 {
  color: #666;
  margin: 20px 10px 0px;
  padding: 0px 30px 0px 30px;
  text-align: center;
}

h3 {
  color: #ccc;
  background-color: black;
  margin: 0px;
  padding: 10px 10px 10px 10px;
  text-align: center;
  display: inline-block;
}
<div>
    <h1>title 1</h1>
    <h3>title 3</h3>
</div>

FIDDLE

like image 321
tanaan Avatar asked Nov 29 '22 00:11

tanaan


1 Answers

Just apply this css property to the div i.e text-align:center;

like this

<div style="text-align:center;">
    <h1>title 1</h1>
    <h3>title 3</h3>
</div>

Here is the example: https://jsfiddle.net/egv269x0/

like image 63
Giulio Bambini Avatar answered Dec 09 '22 19:12

Giulio Bambini