How can I display href as text?

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

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

Is this possible in static HTML without Javascript?

+4
source share
4 answers

No, the HTML standard (a) allows only certain things to be placed in the href URL, and the β€œuse text description as link” marker is not one of those things.

It may be convenient, but I will give it to you, at least in order to save a lot of duplication. Although most people might think that the textual description of the link should be a little more comprehensible to the person than the link.

For example, you would not want to see http://www.google.com/patents?id=vmidAAAAEBAJ&printsec=frontcover&dq=database&hl=en&sa=X&ei=tN-0T-TtKu3TmAWNq7DiDw&ved=0CDUQ6AEwAA on your web page :-)


(a) : The HTML4 standard indicates the element A here and the URI specification here . HTML5 is specified similarly, starting here , with requirements for href .

+1
source

You cannot, you have to either use JavaScript or store it as is.

+1
source

In fact, a good way to format a link is:

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

No, there is no way to remove duplication using static html only.

This is also not necessary. Many webpages use PHP or something like this and making links to PHP is simple :)

PHP example:

 <a href="<?php echo $item->link; ?>"><?php echo $item->link; ?></a> 
0
source

Source: https://habr.com/ru/post/1412961/


All Articles