How To Replace Line Break Tags (
) With Spaces In CSS | TimOnWeb

Tutorials
  • Python
  • JavaScript
  • Django
  • Wagtail
  • DevOps
  • CSS
  • Misc
Services Follow me @twitter Open main menu Services About Contact me

Tutorials

  • Python
  • JavaScript
  • Django
  • Wagtail
  • DevOps
  • CSS
  • Misc
Follow me @twitter CSSCSS How to replace line break tags (<br>) with spaces in CSS

Sep 22, 2020 · Updated: Jul 12, 2021 · by Tim Kamanin

Let's say you have a text separated by line break tags <br>, like this:

One file only.<br /> 50 MB limit.<br /> Allowed types: gif, jpg, png, svg.<br />

And you want to turn the text into a single line, like that:

One file only. 50 MB limit. Allowed types: gif, jpg, png, svg.

If you don't have access to the HTML, you might be tempted to reach for JavaScript, but wait, my friend, put that big gun down, you can solve the task with the only CSS!

The trick here is to use the CSS content property.

We will solve it in two steps:

Step 1

Re-set the content of the line break tag to prevent it from, you guessed it, breaking a line. Add the following CSS code:

br { content: ""; }

Từ khóa » Html Br Substitute