Reputation: 343
This is a simple yes or no question (probably no), googling didn't seem to give me a straight answer. Say you have a link that is
<a href="www.stackoverflow.com">www.stackoverflow.com</a>
Is it possible to make something like
<a href=self.text>www.stackoverflow.com</a>
without using anything else (obviously, no scripts)? Is there any kind of shortcut?
Upvotes: 30
Views: 10391
Reputation: 95
You can do it the other way around.
Use the CSS pseudo class a::before
and set its content
to attr(href)
.
a {
font-family: sans-serif;
font-size: 20px;
}
a::before {
display: block;
content: attr(href);
}
<a href="http://stackoverflow.com"/>
Upvotes: 0
Reputation: 61
create an script/function for that
put a class to all of your anchors (i.e. "anchorTextAsHref" ), get all of them and modify the DOM structure,
just placing the text equals to whatever href has.
let anchors=document.getElementsByClassName("anchorTextAsHref");
for (let i = 0; i < anchors.length; i++) {
anchors[i].text = anchors[i].href;
}
Upvotes: 0
Reputation: 7491
No, you need to have both the href
attribute and a value between the a
tags. Without using any scripts, it's not possible to refer to its own contents.
Upvotes: 19
Reputation: 4714
Use anchor link Useful Tips Section Create a link to the "Useful Tips Section" inside the same document:
Visit the Useful Tips Section
Upvotes: -2
Reputation: 751
I think you're looking for the Anchor Tag . You can use the syntax to link to it, if you reference it by using a <a href="link">
somewhere in the body.
Look here at the bottom for some examples:
http://www.w3schools.com/html/html_links.asp
Upvotes: -3