user2632980
user2632980

Reputation: 551

How to set a background for wrapped text?

I need to set a background for a wrapped text. Is there a way to get this effect via css http://oi40.tinypic.com/ydlk4.jpg.

Upvotes: 0

Views: 76

Answers (4)

NinjaOnSafari
NinjaOnSafari

Reputation: 1016

p {
    /* like this */
    padding: 1px 0;
    /* or */
    border-top: 1px solid black;
    border-bottom: 1px solid black;
    background-color: black;
    display: inline;
    color: #fff;

}

Upvotes: 0

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

Just use display: inline; to your element whatever it is div or p, etc.

Upvotes: 0

Hushme
Hushme

Reputation: 3144

here is a simple solution

http://jsfiddle.net/69RWL/

a {
    display:inline;
    color:white;
    padding:5px 0px;
    line-height:30px;
    background:black;
    font-size:18px;
    text-decoration:none;
}

Upvotes: 0

Maxim Zhukov
Maxim Zhukov

Reputation: 10140

Wrap your text in <span></span>.

Or add display: inline-block with<div></div>

Demo: http://jsfiddle.net/uNjT6/1/

Upvotes: 1

Related Questions