Reputation: 9
I wonder how to make shortcut URL in html and css (if it is possible)
I mean this:
HTML <a href="#URL1">URL1</a>
CSS #URL1 { URL('nextpage.html');}
Is this somehow possible?
Thank you for your answers.
So it can't work like this?
var url1 = "http://www.google.com";
<a href="url1">Google</a>
Is there any option how to do it?
Upvotes: 0
Views: 892
Reputation: 606
Or you can do it with php.
<?php
$url = 'example.com' ;
?>
<a href="<?php echo $url; ?>" >
click here
</a>
Upvotes: -1
Reputation: 1228
To give you the short answer, no, you can't achieve this only by using CSS and HTML.
Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a document written in a markup language. While most often used to change the style of web pages and user interfaces written in HTML and XHTML, the language can be applied to any kind of XML document, including plain XML, SVG and XUL. (...read more)
Also, here is an introduction to what CSS is and how to use it.
I recommend you also take a look at HTML Links.
.attr
and do it like this :SCRIPT
$('#firstlink').attr("href", "http://google.com")
HTML
<a href="#" id="firstlink">This will take you to google</a>
SCRIPT
var url = document.getElementById("firstlink")
url.setAttribute("href", "http://google.com")
HTML
<a href="#" id="firstlink">This will take you to google</a>
Upvotes: 2
Reputation: 606
It can't be possible. As css is for only styling the html. Yes you can target particular url to style it. Check out this page for further detail.
Upvotes: 0