-1

I have an h1 element which gets wrapped in smaller screens How can I make the wrapped text align itself to the center using css?

This is what I want

welcome To our site, the no. 1 site
        to get all ur books
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Abhishek
  • 3
  • 1
  • 6

2 Answers2

1

For Example, the h1 element is this <h1 class="heading">Welcome To our site, the no. 1 site to get all your books</h1>, add this to the css: .heading{text-align:center}

Yung
  • 83
  • 1
  • 2
  • 10
  • Omg Thanks I thought that text-align works for only first line of the text and therefore I did not even try It. Thank you buddy – Abhishek Apr 25 '21 at 15:19
  • @Abhishek Thanks, this is actually the first time my submission got accepted as an answer – Yung Apr 25 '21 at 16:08
  • @Abhishek It works on all text, for ex: HTML:```

    Text

    Text No.2

    ```, CSS: ```.parent{text-align:center;}```, in the code(s) I wrote before, all the Text Elements in the Parent DIV will get centered no matter where it is.
    – Yung Apr 25 '21 at 16:13
0
  • There is no way to be fit for your style.
  • But try to do this way
  <span>
    <h1 style="text-align:center">welcome To our site, the no. 1 site</h1>
    <h1 style="text-align:center">to get all ur books</h1>
  </span>
top talent
  • 615
  • 4
  • 17