HighDots Forums  

How do I centre an <h3> vertically inside a <div>?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss How do I centre an <h3> vertically inside a <div>? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alan Silver
 
Posts: n/a

Default How do I centre an <h3> vertically inside a <div>? - 06-13-2006 , 10:21 AM






Hello,

Please pardon what is probably a dumb question, but if I have HTML like
this...

<div>
<h3>Ferrets</h3>
</div>

and CSS like this...

div {
height: 5em;
}

how do I get the <h3> centred vertically? I tried...

h3 {
margin: auto 0;
}

which worked fine in IE (implying that this is the wrong way to do it!),
but not in FF (implying that this is the wrong way to do it!).

Anyone any suggestion? TIA

--
Alan Silver
(anything added below this line is nothing to do with me)

Reply With Quote
  #2  
Old   
Els
 
Posts: n/a

Default Re: How do I centre an <h3> vertically inside a <div>? - 06-13-2006 , 10:49 AM






Alan Silver wrote:

Quote:
div
h3>Ferrets</h3
/div

and CSS like this...

div {
height: 5em;
}

how do I get the <h3> centred vertically? I tried...

h3 {
margin: auto 0;
}

which worked fine in IE (implying that this is the wrong way to do it!),
and that you IE probably was in Quirksmode,

Quote:
but not in FF (implying that this is the wrong way to do it!).
:-)

Quote:
Anyone any suggestion?
h3{
line-height:5em;
}

Quote:
TIA
You're welcome :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: King Crimson - Indiscipline


Reply With Quote
  #3  
Old   
Alan Silver
 
Posts: n/a

Default Re: How do I centre an <h3> vertically inside a <div>? - 06-13-2006 , 11:54 AM



In article <1un9mwcgcozr$.4v6z9ts1yj27.dlg (AT) 40tude (DOT) net>, Els
<els.aNOSPAM (AT) tiscali (DOT) nl> writes
Quote:
Alan Silver wrote:
snip
I can't reproduce it. Aren't you mistaking the natural top margin of
the h3 in IE for vertical centering?
Could be, never thought of that.

<snip>
Quote:
I have knocked up a small sample to show how it might look, so please
have a look at http://www.kidsinaction.org.uk/h3.html and tell me how
you would centre the <h3> vertically.

No idea, other than using a table cell.
Oh well, thanks anyway. Ta ra

--
Alan Silver
(anything added below this line is nothing to do with me)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.