Contact to Cont...">

Changing href html tag with css

I need to change this tag A from

<a href="contact.html" >Contact</a>

to

<a href="tel:+13174562564" >Contact</a>

only with css if possible or like this

<a href="tel:+13174562564" >+13174562564</a>

I have many pages, and I don’t want to edit them all, which will take a lifetime, so I need to do this in CSS, and I don’t have JS related to them.

+7
source share
4 answers

CSS is only displayed; you cannot change the model of a document object with it. Sorry, this cannot be done. I am sorry that I did not have a better answer, but “this cannot be done” is the only answer.

+24
source

CSS is for presentation and cannot be used to change the layout of HTML as you plan. You need JavaScript to do this.

script.

+9

one solution is to hide the tag and put another

<div id="tag1">
<a href="#tag1">link1</a>
<a href="#tag2">link2</a>
</div>

css:

a[href="#tag1"] {
display:block;
}

a[href="#tag2"] {
display:none;
}

#tag1:target  a[href="#tag1"]{
 display:none;
}

#tag1:target  a[href="#tag2"]{
 display:block;
}

I use this method for responsive "buttons" in my menu bar

+2
source

I made it very easy using jQuery.

 $(".website").click(function () {
        window.open("https://www.website.com", "_blank");
 })
0
source

All Articles