How do I make entire div a link? [duplicate]

Tags: html,css

Problem :

This question already has an answer here:

I have a div like this <div class="xyz"></div> and all the content in that div is in the css. How do I make that div into a link? I tried wrapping the a tag around it, but that didn't seem to work.


Solution :

You need to assign display: block; property to the wrapping anchor. Otherwise it won't wrap correctly.

<a style="display:block" href="">
  <div class="xyz">My div contents</div>

    CSS Howto..

    How can I create a horizontal selector in a form with only html and css?

    How can i get target with a hover an element under an element?

    How to do page / content transitions

    How to make the green DIV fit right after 2 upper divs?

    How to start with responsive deisgn [closed]

    How can I use the CSS pseudo-element :before{ content: '' } to affect an

    CSS IE7 How can I force UL inside LI to be wider than the parent

    How to blink a text on button in IE ,chrome etc using JQuery or CSS

    How to remove spacing between tags?

    How to resize an image in pure HTML/CSS while keeping its proportions?

    How do prevent a div from resizing? [closed]

    How to disable the collapsing feature in twitter bootstrap 3?

    How do I execute a javascript after Ajax load?

    How do I make my text disappear when I hover over my div?

    How to apply default CSS styling to all HTML pages

    How to add fade in and fade out effect in CSS animations no javascript?

    How can I skin / theme a windows forms application [closed]

    How to avoid display block for a particular div element using css

    How to get 'div' shaped as a flag with CSS

    How to fade out after hover is done using CSS

    how to make a double hover effect with css

    How can I use :before property to create a square before a span

    How can I change this HAML format to normal CSS style?

    How to set different css attributes with JQuery?

    How to override a *{list style:none} property

    How to use a text file's contents in HTML as text [duplicate]

    how to make sure that that grid layout row adjusts the height automatically as per content

    How can I make use of `::selection` for in chrome browsers?

    How to mail HTML/CSS output as attachment?

    How can I add a default to my CSS slide show banner?