Skip to main content
Inspiring
Jan 12, 2018 8:48 PM UTC
Answered

link a logo via div

CSS-Tricks mentioned that to hyperlink your logo you can surround a div with the <a> tags.

<a href="http://example.com"> <div> anything </div> </a>

How would it work in this case?

<div class="col-sm-12 col-lg-12 clearfix">

       <a target="_blank" href="#"><div class="logo"><img src="images/logo.png" class="img-responsive" alt="Logo"></div></a>            

</div>

I tried this but it did not seem to work. I tried it on a local server for testing. Can you advise if something is incorrect here?

Thank you!

    This topic is closed to new replies. Start a new post to keep the conversation going.
    WolfShade
    WolfShadeCorrect answer
    Legend
    Jan 12, 2018 9:15 PM UTC

    Seems pretty straightforward.  No reason it shouldn't work.

    <DIV>

        <A>

            <DIV>

                <img />

            </div>

        </a>

    </div>

    V/r,

    ^ _ ^

    7 replies

    BenPleysier
    Community Expert
    Community Expert
    Jan 12, 2018 11:29 PM UTC

    Adding to WolfShade​ reply, you will have to replace the '#' in <a target="_blank" href="#"> with the destination such as

    <a target="_blank" href="myPage.html"><div class="logo"><img src="images/logo.png" class="img-responsive" alt="Logo"></div></a> 

    As a side note: Because Bootstrap 3+ is a mobile first framework it is not neccessar to add all of the classes as in <div class="col-sm-12 col-lg-12 clearfix">. You can remove the class for lg as in

    <div class="col-sm-12 clearfix">

    Translate
    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    r_tistAuthor
    Inspiring
    Feb 7, 2018 4:15 PM UTC

    I cannot get this specific use case to work:

    <div class="col-sm-12 clearfix">

        <div class="logo">

         <a target="_blank" href="https://www.google.com"><img src="images/logo.png" class="img-responsive" alt="The Logo"></a>

         </div>

    </div>

    I just need the .png of logo to link out actively. As is, it does not work at all. Do the <a> tags get pulled out and surround the logo div class instead?

    Thank you.

    Translate
    WolfShade
    Legend
    Feb 7, 2018 4:54 PM UTC

    No.  Unless there is some extenuating circumstance, the code you provided should work.  What, precisely, isn't working?

    V/r,

    ^ _ ^

    Translate
    WolfShade
    WolfShadeCorrect answer
    Legend
    Jan 12, 2018 9:15 PM UTC

    Seems pretty straightforward.  No reason it shouldn't work.

    <DIV>

        <A>

            <DIV>

                <img />

            </div>

        </a>

    </div>

    V/r,

    ^ _ ^

    Translate