Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap "class=text-center" vs. CSS "text-align: center"

We may possibly stop using the Bootstrap framework, so I want to know if replacing class="text-center" with vanilla CSS will change anything. Is there any difference in behavior between

<!--Bootstrap files already included-->
<header>
    <p class="text-center">Some text</p>
</header>

and

<header>
    <p>Some text</p>
</header>

...

/*Separate style.css file*/
header p {
    text-align: center;
}

?

like image 761
Aposhian Avatar asked Oct 16 '25 05:10

Aposhian


1 Answers

The OP's question seems to have been edited after it was first posted. It essentially asks: whether Bootstrap does anything extra to elements with the class .text-center, in addition to text-align: center;. I also had this doubt and the answer is no. I think this question can be better answered by just looking at Bootstrap's source code:

.text-center {
  text-align: center !important; }

Apparently all that Bootstrap does is to apply one CSS rule: text-align: center !important; to such an element. So yeah they can be considered equivalent.

like image 154
xji Avatar answered Oct 18 '25 22:10

xji