One thought on “How to Show a div on hover using only CSS

  1. Hello Earl

    Assuming HTML4, with this layout:


    < a >Hover over me!< /a >
    < div >Stuff you want to show< /div >

    You can do something like this:
    div {
    display: none;
    }

    a:hover + div {
    display: block;
    }

    This uses the adjacent sibling selector. However this is a very general solution which would hide all you div tags. You probably want to assign the div tag a class and use that in the CSS

    In HTML5 you can anchor elements to wrap almost anything, so in that case the div element can be made a child of the anchor.

    Hope that helps

    Will

Comments are closed.