+ 1
How to place headings at the center
which tag is used
5 Answers
+ 3
<h1 align="center">heading</h1>
this is correct one
+ 2
Element <center> is deprecated, you must do not use it.
You must avoid 'align' attribut also, which is deprecated and only use ccs...
Correct css property syntax is:
text-align:center;
You can use any html element you want to build your heading, but it's greatly recommended to use those that are semantical meaningful.
<h1> and other family <hx> tags ( where x from 1 to 6 ) are intended to only have text childs elements ( even they can, their meaning is more "title" than "header" ), and newly html5 <header> is more generic header meaning...
[ edit ]
text-align:center; align the content of the element... <hx> and <header> are block-level elements, and the default behavior is to get the max width: so, it's the default correct way to do this.
If you define a fixed width to the element, you can align a block-level element ( the box, not it's content) in its parent by applying 'auto' margins:
/* align to center... could be write: margin:v auto; or margin:vt auto vb; for setting respectivly v, vetical margins, vt, top margin, vb bottom margin... */
margin:auto;
/* align to right */
margin-left:auto;
/* align to left... but this is the default behavior of a block-level element :P */
margin-right:auto;
+ 1
/t/t/t - should work
+ 1
<center> it needs end too with /
+ 1
There are many ways. you can make it
<h1 align="center"></h1> or in css
h1 {
align: center;
}