1

For example, this JSFiddle: https://jsfiddle.net/qmn8q2ck/

<p>
    <span> This is some multiline text. This is some multiline text. </span><span>This is some multiline text. This is some multiline text. This is some multiline text. This is some multiline text. This is some multiline text. This is some multiline text. This is some multiline text. </span>
</p>

span {
    background-color: red;
    display: inline;
}

enter image description here

However, I noticed that browser highlighting doesn't have spaces between lines, and has the effect that I would like.

enter image description here

How do I get this effect?

Edited to show need for display:inline and effecting the span elements as opposed to the whole paragraph.

knightian
  • 683
  • 1
  • 7
  • 20

3 Answers3

3

Also you can add to your span css display:inline-block

span {
  background: red;
  display: inline-block;
}

DEMO : http://jsfiddle.net/qmn8q2ck/

OR add padding

DEMO : http://jsfiddle.net/ckhfa8hc/

span {
  background-color: red;
  display: inline;
  padding-top: 1px;
}
Joe Koker
  • 931
  • 10
  • 20
1

With css line-height property

p { /* or span as you like */
   line-height: 90%; /* Try some values here */
}
Carlos2W
  • 2,024
  • 2
  • 16
  • 19
  • Is it possible to do this without changing the line height? I would effectively like to increase the "content" area without changing the actual appearance. – knightian Jul 14 '15 at 17:06
  • I did this, and for larger line-heights, I added padding. – knightian Jul 14 '15 at 17:16
1

could you please explain your problem in detail? .. from what i understood..

you should probably apply background-color property to the paragraph instead of the span

p { background-color: red; }

try this

Omkar Kulkarni
  • 784
  • 6
  • 12