Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Given an example html snippet that I cannot change, is there a **CSS only** approach to make text before <br> as bold and after <br> as normal?

I have this html

<div class="html-input goto-card-label">Header <br> Subtitle</div>

CSS is making the entire label bold:

.goto-card-label {
  font-weight: bold;
}

Is there a CSS only approach to make the text after the <br> tag as font-weight: normal; without changing the html at all?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Note: I likely cannot use the content css property since the text will not always be what I put in the example.

>Solution :

You can approach your problem using ::first-line pseudo-element to the first line of the text within div element.

.goto-card-label::first-line {
  font-weight: bold;
}
<div class="html-input goto-card-label">Header <br> Subtitle</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading