HTML hyperlink with image and text

Is it possible to make a hyperlink look like a button with text on it?

We can make a hyperlink button with the code:

<a href="..."> <img src="button.png" width="100" height="50" alt="Some text"></img> </a>

but I also need a TEXT in the center of the button.

Thank.

+5
source share
3 answers

This is possible by setting the button as the background:

<a href="..." style="text-align:center; background: url('button.png'); width: 100px; height: 50px;">Your text</a>

But I will try to avoid buttons with background images (unless they were a strange shape). Instead, I would try using CSS3.

+3
source

I would suggest, not knowing exactly what you want, and assuming the following inscription:

<a href="#"><img src="path/to/image.png" /><span>Some text</span></a>

a {
    position: relative;
    display: inline-block;
}

a span {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -1em;
    margin-left: -50%;
    width: 100%;
    height: 2em;
    color: #f90;
    background-color: rgba(0,0,0,0.5);
}​

JS Fiddle demo .

0
source

, bootstrap Flat ui.

<a href="#" class="btn btn-primary"> Click Me</a>
0

All Articles