HTML / CSS: creating a <a> tag with css

I have a phone number and I want to associate it with CSS. The phone number is the background (CSS) inserted into the div. Is this possible with CSS?

problem ... I have many pages and I only have a css page linked to all of these pages. "no JS" and I don't want everyone around to change the "div" to "a".

+4
source share
5 answers

Yes, instead of div use the a element as follows:

 a.phone-number { display: block; width: ...; height: ...; background: url(...); } 

and then your html will be

 <a href="#url#" class="phone-number"></a> 
+2
source

instead of div make background image of example a below

Hmtl

 <a href="#">phone</a> 

CSS

 a.{ float:left; width:100px; height:200px; text-indent:-5000px; background: url(images/sample.jpg); } 

hope this helps

+1
source

No, you cannot create links to CSS. CSS is intended to provide suggestions, not to improve functionality or add new elements.

+1
source

Something like that?

 <div class="number"></div> 

 .number{ /* mention the div class name or id here */ display:inline; cursor: pointer; cursor: hand; /*for cross-browser support */ border-bottom: 1px solid blue; /* give your own color */ } 
0
source

You need to use the <a> tag. <a> is a semantically correct element that gives you more markup.

Using HTML5, you should mark your phone connection like this.

 <a href="tel:+13174562564">317-456-2564</a> 

This allows mobile devices such as iPhone and Androids to recognize them as a phone number and initiate a phone call when touched.

0
source

All Articles