- [ Solved – 11 Answers ] CSS – HTML – Make a div into a link
- HTML:
- CSS:
- Open in new window :
- Open in same window :
- The code :
- This is one of the solution :
- Try this code :
- You can give a link to your div by following method:
- You can make surround the element with a href tags or you can use jquery and use
- How to Modify the URL without reloading the page
- [Solved – 10 Answers] Click through a DIV to underlying elements
- How to remove border (outline) around text/input boxes
- How to apply CSS to iframe
- Is there a “previous sibling” CSS selector
- Offsetting an html anchor to adjust for fixed header
- CSS Links
- Styling Links
- Example
- Example
- Text Decoration
- Example
- Background Color
- Example
- Link Buttons
- Example
- More Examples
- Example
- Example
- Example
- COLOR PICKER
- Report Error
- Thank You For Helping Us!
[ Solved – 11 Answers ] CSS – HTML – Make a div into a link
But most-likely what you really want is to have an tag displayed as a block level element.
HTML:
CSS:
Open in new window :
Open in same window :
- Here’s how to make a div into a clickable link that will open the target URL into the same window.
The code :
- You could also try by wrapping an anchor, then turning its height and width to be the same with its parent.
This is one of the solution :
Try this code :
You can give a link to your div by following method:
You can make surround the element with a href tags or you can use jquery and use
Wikitechy Editor
Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I’m a frequent speaker at tech conferences and events.
Related Tags
- clickable div bootstrap,
- div a css,
- div link html,
- div link yale,
- how to give link to div tag in html,
- How to Make a div a Clickable Link — HTML & CSS,
- How to make a whole div clickable?,
- href to div on same page,
- html — How do I make entire div a link?,
- html — How do you make a div tag into a link,
- Javascript — Make Div Into A Clickable Link,
- Make a whole div clickable,
- make div clickable javascript,
- make div clickable jquery,
- Make Entire Div Clickable,
- Turn an Entire DIV into a Clickable Link
Leave a Reply
You May Also Like
How to Modify the URL without reloading the page
PROBLEM: How to Modify the URL without reloading the page? SOLUTION 1: Updating address bar with new URL without hash or reloading the page Example: [pastacode lang=”javascript” manual=”%20function%20processAjaxData(response%2C%20urlPath)%0A%7B%0A%20%20%20%20%20document.getElementById(%22content%22).innerHTML%20%3D%20response.html%3B%0A%20%20%20%20%20document.title%20%3D%20response.pageTitle%3B%0A%20%20%20%20%20window.history.pushState(%7B%22html%22%3Aresponse.html%2C%22pageTitle%22%3Aresponse.pageTitle%7D%2C%22%22%2C%20urlPath)%3B%0A%20%7D%0A%0A” message=”javascript code”…
[Solved – 10 Answers] Click through a DIV to underlying elements
PROBLEM we have a div that has background:transparent, along with border. Under this div, we have more elements. Currently, we able to click the underlying elements when we click outside…
How to remove border (outline) around text/input boxes
PROBLEM: How to remove the orange or blue border (outline) around text/input boxes? It only happens on Chrome to show that the input box is active. Here’s the input CSS…
How to apply CSS to iframe
HTML – CSS – iframe css example – How to apply CSS to iframe – An IFrame (Inline Frame) is an HTML document embedded inside another HTML document on
Is there a “previous sibling” CSS selector
Explaining about CSS Selector Cascading Style Sheets: A CSS selector is the part of a CSS rule set that actually selects the content you want to style. CSS Syntax: A CSS rule-set consists of a…
Offsetting an html anchor to adjust for fixed header
PROBLEM: Offsetting an html anchor to adjust for fixed header? SOLUTION 1: You could use CSS without any javascript. Give your anchor a class: [pastacode lang=”markup” manual=”%3D%22%3Ca%20classanchor%22%20id%3D%22top%22%3E%3C%2Fa%3E%0A” message=”HTML CODE” highlight=””…
CSS Links
With CSS, links can be styled in many different ways.
Styling Links
Links can be styled with any CSS property (e.g. color , font-family , background , etc.).
Example
In addition, links can be styled differently depending on what state they are in.
The four links states are:
- a:link — a normal, unvisited link
- a:visited — a link the user has visited
- a:hover — a link when the user mouses over it
- a:active — a link the moment it is clicked
Example
/* unvisited link */
a:link color: red;
>
/* visited link */
a:visited color: green;
>
/* mouse over link */
a:hover color: hotpink;
>
/* selected link */
a:active color: blue;
>
When setting the style for several link states, there are some order rules:
Text Decoration
The text-decoration property is mostly used to remove underlines from links:
Example
a:visited text-decoration: none;
>
a:hover text-decoration: underline;
>
a:active text-decoration: underline;
>
Background Color
The background-color property can be used to specify a background color for links:
Example
a:link <
background-color: yellow;
>
a:visited background-color: cyan;
>
a:hover background-color: lightgreen;
>
a:active background-color: hotpink;
>
Link Buttons
This example demonstrates a more advanced example where we combine several CSS properties to display links as boxes/buttons:
Example
a:link, a:visited <
background-color: #f44336;
color: white;
padding: 14px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
>
a:hover, a:active background-color: red;
>
More Examples
Example
This example demonstrates how to add other styles to hyperlinks:
Example
Another example of how to create link boxes/buttons:
a:link, a:visited <
background-color: white;
color: black;
border: 2px solid green;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
>
a:hover, a:active background-color: green;
color: white;
>
Example
This example demonstrates the different types of cursors (can be useful for links):
COLOR PICKER
Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
Thank You For Helping Us!
Your message has been sent to W3Schools.
Top Tutorials
Top References
Top Examples
Get Certified
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.