Reputation: 137
I want to style the first label in <p>
tag.
I want first label font size 20px while 2nd label size 10px. I know by using ids and classess. But I want like
p->first:label
Thanks in advance.
Upvotes: 1
Views: 76
Reputation: 11496
I suggest to use nth-of-type()
html
<p>
<label>this is a label</label>
<label>this is a label</label>
<label>this is a label</label>
<label>this is a label</label>
</p>
css
p label:nth-of-type(1) {
color: red;
}
Upvotes: 0
Reputation: 1
Might be better to actually use :first-of-type
, so:
p > label { font-size: 10px; }
p > label:first-of-type { font-size: 20px; }
Upvotes: 0
Reputation: 409
p label { font-size:10px;}
p label:first-child { font-size:20px;}
Upvotes: 2
Reputation: 13978
you can use first-child
p label:first-child
{
/* your style */
}
Upvotes: 0