How do you make a heading be aligned to the center? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

How do you make a heading be aligned to the center?

I tried <p align="center"><h1>Content is here</p></h1>, when I took away the heading it worked but with the heading it doesn't work.

14th Mar 2016, 9:35 PM
4 Answers
+ 3
This way you're putting your head into your body. Headings and paragraphs are tags sharing the same level of importance. If you want a heading being aligned to the center write (outside the <p>...</p>) <h1 align="center">Centered Heading1</h1>.
10th Apr 2016, 7:47 PM
Aleksandr Novakov
Aleksandr Novakov - avatar
+ 1
Or you could do it in CSS. h1 { text-align:center; }
11th Jun 2016, 2:04 AM
Charlie Plett
Charlie Plett - avatar
you could also try: <center><h1> Some Text</h1></center>
4th Jun 2016, 10:57 AM
Gabe Rust
Gabe Rust - avatar
put your align attribute in the header tag not the paragraph tag. Here is what I mean <p><h1 align="center">Header is centrally aligned </h1></p> That should work
14th Jun 2016, 5:20 AM
Toluwalope Rodney Coast
Toluwalope Rodney Coast - avatar