how to center the headings? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to center the headings?

12th Jun 2016, 3:44 AM
Melkisedek Ubalde
Melkisedek Ubalde - avatar
7 Answers
+ 5
Never use HTML for layout and style. Use CSS instead. To center lines of text, like headings and paragraphs, use this: H1 { text-align: center } P { text-align: center } To use it inline: <H1 style="text-align: center">A Heading</H1>
12th Jun 2016, 8:31 AM
ZinC
ZinC - avatar
+ 1
@Patrick margin: auto; will only center a block if it's less than 100%. But even then, the text is still left aligned. text-align:center; centers the text not the block, wich in this case is a heading or a paragraph that's 100% wide by default.
12th Jun 2016, 10:17 PM
ZinC
ZinC - avatar
0
use in CSS sheet h1{text-align:center;}
12th Jun 2016, 8:33 AM
sai aravind
sai aravind - avatar
0
using css you can set margin to 0 auto to center the block
12th Jun 2016, 9:42 PM
Patrick T.
Patrick T. - avatar
0
By using CSS ex: h1{text-align:center}
18th Jun 2016, 1:53 AM
Seham Farouk
Seham Farouk - avatar
- 1
By using "align" attribute For example <h1 align="center"> your text </h1>
12th Jun 2016, 5:58 AM
Pankaj Vaghela
Pankaj Vaghela - avatar
- 1
<center>
13th Jun 2016, 9:30 PM
feisal
feisal - avatar