Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to select the first character? :first-letter does not seem to work [duplicate]

Example problem: http://jsfiddle.net/6WYXk/

I have some html: <p>% hello world</p>

I want to make the % bold. To do this usually I would write this in CSS:

p:first-letter
{
    font-weight: bold;
}​

However that makes the % and the h bold.

Ideally I'd like a psudeo selector of :first-character

like image 985
Greg Avatar asked May 16 '12 07:05

Greg


2 Answers

Indeed, that's odd. Doesn't work for other symbol chars as well and the same problem has been discussed elsewhere on SO as well.

You should try something like this:

<p>hello world</p>
p:before { content:"%"; font-weight: bold; padding-right: 5px;}

​ Try it yourself…

like image 124
Michael Seibt Avatar answered Oct 17 '22 10:10

Michael Seibt


Your can write like this:

<p><span>%</span> hello world</p>

Check this http://jsfiddle.net/6WYXk/30/

like image 43
sandeep Avatar answered Oct 17 '22 11:10

sandeep