CSS selector to target the last of the br tags that fall into pairs in the p tag?

I would like to normalize the spacing between line breaks and paragraphs in some text.

To do this, I want to collapse all line breaks so that they do not display the height by themselves, and then add margin-bottom to the last of two consecutive tags <br>.

Is there a css selector that allows me to select the last tag <br>that falls into pairs inside <p>?

<p>
   Some text<br />
   Some more text<br /><br /> <!-- I wan't to target the last of these -->
   Even more text<br /> <!-- Not this one -->
</p>

I tried the following selectors, but not cubes. It seems that selector + ignores the text and becomes greedy.

p br {
    line-height: 0;
    height:0;
    margin:0;
    padding:0;
    content: " ";
    display: block;
}

p br + br {
    margin-bottom: 1em;
}

Example: http://jsfiddle.net/jqcyc/

Is this possible with this markup, preferably without javascript?

+4
3

, , CSS. HTML, CSS :

<p>
    <br />
    <br /><br /> <!-- I wan't to target the last of these -->
    <br /> <!-- Not this one -->
</p>

, <br />, p br + br. , ( CSS).

JavaScript ( , - PHP, Java ..).

+6

br, br:nth-child(n) .

: br:nth-child(2){ height:12345px; }

+2

CSS-. <br />, ( ). jsfiddle http://jsfiddle.net/jqcyc/5/

+1

All Articles