Bootstrap 5 Responsive Text and Alignment

659 views Asked by At

I want to make my div element centered but the text alignment is on the left. Code:

 <div class="container">
      <div class="row">
        <div class="col">
          <h1><strong>Hello, what we can do for you?</strong></h1>
        </div>
      </div>
</div>

I tried to put text-center in the container and put text-align left for col class, but the thing is my div element and the text both centered. I can't configure how to make the text alignment to the left. Failed attempt:
HTML

 <div class="container text-center">
      <div class="row">
        <div class="col">
          <h1><strong>Hello, what we can do for you?</strong></h1>
        </div>
      </div>
</div>

CSS:

.col{text-align:left;}
1

There are 1 answers

0
AudioBubble On

TEXT WITH CENTER ALIGN

<div class="container text-center">
    <div class="row">
        <div class="col">
            <h1><strong>Hello, what we can do for you?</strong></h1>
        </div>
    </div>
</div>

TEXT WITH LEFT ALIGN

<div class="container">
    <div class="row">
        <div class="col">
            <h1><strong>Hello, what we can do for you?</strong></h1>
        </div>
    </div>
</div>