Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display the href as the text too?

Tags:

html

href

anchor

I would like to get the same result as below but without the duplication (the same link appears twice):

<html>
<body>
<a href="http://www.w3schools.com">http://www.w3schools.com</a>
</body>
</html>

Is it possible in static HTML without Javascript?

like image 808
Ali Avatar asked May 17 '12 11:05

Ali


1 Answers

You can do this without duplication using CSS selectors, by using the attr function in CSS.

In your style sheet you can add this:

a::after {
    content: attr(href);
}

For your example in the question:

<html>
<style>
a::after {
        content:  attr(href);
}
</style>
<body>
    <a href="http://www.w3schools.com">Some text</a>
</body>
</html>

And it displays the link after Some text.

like image 173
Siham Avatar answered Nov 01 '22 06:11

Siham