March 10, 2012

remove line height from the second line

Question by Sowmya Shivaram

I have given line height of 60px for a tag but wen content is more, it goes to second line but even second line is taking line height of 60px. How do I remove line-height from second line?

Here line height is necessary to vertically middle align the text to div.

a.pname
{ font-family:Verdana, Geneva, sans-serif; font-size:14px; 
color:#000; text-align:left; font-weight:normal;
text-decoration:none; line-height:65px; 
float:left; background-color:#090; width:190px 
}

Answer by Starx

Use :first-line pseudoelement to select only the first line. Remove the line-height property from your style and add this

a.pname:first-line { line-height: 65px; }

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!