1

I am having some trouble with my h3 not being aligned at the top of the div (as I trying). Vertical-align and line-height just does not seem to do it. Are there any options that I've overlooked?

1
  • What exactly do you consider "align to the top"? Keep in mind that fonts leave a space above capital letters, so that diacritics have enough space. Compare A Ä.
    – RoToRa
    Sep 1, 2011 at 13:23

2 Answers 2

3

Reset default browser margins and paddings.

h3 {padding:0;margin:0;}

Otherwise post your code if you want better feedback.

2
  • I can't believe i forgot the margin and padding. It worked perfectly! Thanks alot Sep 1, 2011 at 13:20
  • @OptimusCrime - nice - approve answer for others to know it solved.
    – easwee
    Sep 1, 2011 at 13:21
3

Relative positioning on the div and absolute top positioning on the h3 is another way of achieving this. Will need to add padding to the top of the div also. E.g.

div { position: relative; padding-top: 20px; }
h3 { position: absolute; top:  0; right: 0; left: 0; font-size: 18px; line-height: 20px; }
1
  • This is overcoding. Also a good recipe for troubles with content that comes after h3.
    – easwee
    Jan 14, 2014 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.