How to make a div tag clickable


In Html we have the Anchor tags which is a clickable element, so if you have a div tag or any other tag like span or p you can make it clickable simply by wrapping it with an anchor tag. Let's see an example,

Example :

<div style="background-color:#09C;color:#fff;padding:20px;margin:20px">Div tag : Not Clickable</div>

Result :

Div tag : Not Clickable

Now simply wrap the above div with an anchor tag, note if you have some text within your div tag and you don't want it to be underlined as in case of a hyperlink, just add textdecoration:none in the style tag.

Example :

<a href="http://code2care.org" style="text-decoration:none">
<div style="background-color:#09C;color:#fff;padding:20px;margin:20px">This is my div tag : Clickable</div>

Result :

This is my div tag : Clickable


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap