Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding link a href to an element using css [duplicate]

Tags:

html

css

Can I add an <a href=""> link to an HTML element using CSS. As I have an image which I want to add a link to a particular page. Can any one help me in doing this?

like image 226
amit Avatar asked Jun 04 '13 05:06

amit


People also ask

How do you add a href to a link in CSS?

You can refer that. $('#link'). attr('href','http://www.google.com'); This single line will do the trick.

How do you duplicate elements in CSS?

Short answer no, in css you can't create content or display it multiple times. Usually this repeated content is taken care of via server side technologies (PHP, JSP, ASPX) etc. If your site is static content (no server side processing) then your best bet is just copy and past.

Can I add href in div?

Divs are HTML elements that are delineated with the tags <div> and </div>. Attributes are key/value properties that are attached to an element like so <a href=”this is the value of the href attribute”>. You cannot use a tag as an attribute or attribute value.

How do you reference a link in CSS?

The :link selector is used to select unvisited links. Note: The :link selector does not style links you have already visited. Tip: Use the :visited selector to style links to visited pages, the :hover selector to style links when you mouse over them, and the :active selector to style links when you click on them.


1 Answers

No. Its not possible to add link through css. But you can use jquery

$('.case').each(function() {
  var link = $(this).html();
  $(this).contents().wrap('<a href="example.com/script.php?id="></a>');
});

Here the demo: http://jsfiddle.net/r5uWX/1/

like image 59
Selvamani Avatar answered Sep 26 '22 01:09

Selvamani