Rod
Rod

Reputation: 15477

css bold first line in div

I have a bunch of divs like the following on one page. Is there a way in css to bold just the first line (before the <br/>)? So, in this instance, I would want Customer in bold.

<div>
Customer
<br/>
John Doe
</div>

Upvotes: 5

Views: 4025

Answers (5)

Sachin
Sachin

Reputation: 48

I am not too good at css but hope this pseudo-element doucmentation help more to lean about pseudo selectors. and Thanks to @MKN Web Solutions for great and quick answer.

http://www.w3.org/TR/css3-selectors/#first-line

Upvotes: 0

Sinan &#220;n&#252;r
Sinan &#220;n&#252;r

Reputation: 118166

There is a ::first-line selector. According to QuirksMode, it is widely supported. MDN provides more information.

Upvotes: 0

Michael Mikhjian
Michael Mikhjian

Reputation: 2794

Yes, you're looking for the ::first-line pseudo-element.

So basically you'd do:

div::first-line{
 font-weight:bold
}

Upvotes: 13

j08691
j08691

Reputation: 208032

use the :first-line pseudo-element:

div::first-line {
    font-weight:bold;
}
<div>
Customer
<br/>
John Doe
</div>

Upvotes: 4

DaniP
DaniP

Reputation: 38262

Use pseudo-element ::first-line

div::first-line {
  font-weight:700;
}
<div>
Customer
<br/>
John Doe
</div>

Upvotes: 2

Related Questions