Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap center heading

It is my first Twitter Bootstrap experience. I have added some headings (h1, h2, etc.) and they are aligned by left side. What is the right way to center headings?

like image 398
SiberianGuy Avatar asked Jun 22 '12 11:06

SiberianGuy


People also ask

How do you center a heading in bootstrap?

In the current version of bootstrap 5.2. 0 it is: text-center, (center) text-end, (right) text-start, (left).

How do I center a label in bootstrap?

Add text-align: center in your CSS or text-center class to your parent element (probably to a row or container ).

How do I center text in bootstrap?

Add class . text-center to the parent div to align text or any item inside to the center. You can also decide how the alignment should look like on the specific screen sizes.


2 Answers

.text-left {   text-align: left; }  .text-right {   text-align: right; }  .text-center {   text-align: center; } 

bootstrap has added three css classes for text align.

like image 57
Jinpu Hu Avatar answered Oct 10 '22 08:10

Jinpu Hu


Just use class='text-center' in <h> element for center heading:

<h2 class="text-center">sample center heading</h2> 

Use class='text-left' in <h> element for left heading, and use class='text-right' in <h> element for right heading.

like image 21
Sadegh-khan Avatar answered Oct 10 '22 07:10

Sadegh-khan