user1622638
user1622638

Reputation: 11

CSS, background color/image

I want to add some background colour to block h1 tag but I don't want to see background behind the text. Is it possible?

For example background with (-), It will seen like this:

Welcome -----------------

after text like filling with (-)

Thanks for help

Upvotes: 0

Views: 137

Answers (2)

Ghassan Elias
Ghassan Elias

Reputation: 2233

<style type="text/css">
h1 {
    width: 200px;
    background-image: url(line.png);
    background-repeat: repeat-x;
    background-position: left bottom;
}

h1 span {
    background-color: #FFF;
}
</style>


<h1><span>Welcome</span></h1>

see this example: http://jsfiddle.net/WtPB5/2/

Upvotes: 0

NedStarkOfWinterfell
NedStarkOfWinterfell

Reputation: 5243

Declare the h1 tag as as inline-block, and keep it within a div. Assign th required the background color to the div while assigning a background of white to the h1. You will get the desired effect.

Upvotes: 1

Related Questions