PDA

View Full Version : centre aligning H tag within a div


JBD
08-09-2011, 01:24 PM
What's the correct way to centre align a h tag within a div?

My code:

h3 {
font-size: 13px;
font-weight: bold;
font-style:italic;
color: #333333;
}

#SVquote {
width: 576px;
float: left;
display:inline;
margin:auto;
padding: 10px;
border: 0px;
clear:both;
}

<div id="SVquote">
<h3 align="centre">A diverse range of vintage industrial furniture suitable for home and business</h3>
</div>

I can't seem to centre align the text within the containing div

Corrosive
08-09-2011, 03:58 PM
I believe the display inline is the issue. It needs to be block (natural) to align text inside. Try losing that and then adding text-align: center; to the div styles and see what that does.

JBD
08-09-2011, 04:10 PM
This is what I have now but it still doesn't seem to work?

h3 {
font-size: 13px;
font-weight: bold;
font-style:italic;
color: #333333;
text-align:centre;
}
#SVquote {
width: 576px;
float: left;
display:block;
margin:auto;
padding: 10px;
border: 0px;
clear:both;
}

<div id="SVquote">
<h3>A diverse range of vintage industrial furniture suitable for home and business</h3>
</div>

domedia
08-09-2011, 04:35 PM
'center' not 'centre'

JBD
08-09-2011, 04:41 PM
lol I need to remember to use American English! cheers :)

Corrosive
08-09-2011, 04:53 PM
lol I need to remember to use American English! cheers :)

I find myself spelling colour without a 'u' a lot now *shudder*.

edbr
08-16-2011, 01:59 AM
don't get me started!