Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove multiple extra break tags with CSS

Tags:

html

css

layout

I have this HTML with multiple <br> tags.

<br>
<br>
<br>
<br>
<br>
TITLE
<br>
<br>
foo bar
<br>
foo bar
...

I want to keep only single and double breaks at most (new line and new paragraph) and I want to ignore all extra <br>. So having maximum 2 <br> one after another. So,

<br><br><br><br><br>TITLE<br><br>foo bar<br>foo bar<br><br><br>foo bar

would become

<br><br>TITLE<br><br>foo bar<br>foo bar<br><br>foo bar

How can I do this with CSS?

I would like to select all <br> elements who have at least 2 immediate previous <br> siblings

EDIT: for a bit more of context, the HTML is on an external web site, I try to improve the reading with firefox/stylish, so only with CSS

like image 564
oluc Avatar asked Sep 06 '12 07:09

oluc


1 Answers

By using :nth-child selector you can achieve it easily.

CSS:

br:nth-child(3n + 3) { display: none; }​

SEE DEMO

like image 146
Ahsan Khurshid Avatar answered Sep 19 '22 16:09

Ahsan Khurshid