The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Is using a Href in Div OK?

    Is using a Href in Div OK?

    Technical SEO Issues
    7 4 3.0k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • James77
      James77 last edited by

      Hi,

      I was just wondering what your thoughts are on using a Href in a Div, which contains anchor text. We currently use the Href on the div, as opposed to just the anchor text as I want the whole div to be clickable as opposed to just the anchor text.

      So currently I have:

      Keword 1
      Keyword 2

      Is this perfectly fine to do it like this as opposed to using <a tags="" ???<br="">I suppose there are various alternatives - if you must use the</a><a tag="" like:<="" p=""></a>

      <a tag="" like:<="" p=""></a>

      Keword 1
      Keyword 2

      However I would assume a search engine is smart enought to know its the same thing???

      Thanks

      1 Reply Last reply Reply Quote 0
      • RyanKent
        RyanKent last edited by

        Neither option is valid HTML. Browser behavior and crawler behavior would be unpredictable.

        The code would be something like:

        Keword 1
          

        James77 1 Reply Last reply Reply Quote 1
        • Maximise
          Maximise last edited by

          I would try and stay clear of doing this to be honest. It won't validate, older browsers may have problems with it and I'm not sure how search engines would treat it (they may not follow it). There are better ways to do it.

          If you set your anchor tag to 'display:block' you can then set the height and width too. This way the whole div would be the link, not just the text.

          1 Reply Last reply Reply Quote 3
          • blackballonline
            blackballonline last edited by

            Any time I have a question about valid HTML I go to the Source. W3C has an invaluable tool for HTML . Becoming familiar with this will help you always create clean code.

            1 Reply Last reply Reply Quote 2
            • James77
              James77 @RyanKent last edited by

              Jesus - Thanks.

              So your telling me that its totally invalud to:
              1/. Wrap a href tag around a div tag.

              2/. Put a href tag as an atribute on a div tag.

              If that is the case I'm going to have so serious words with my coders!!

              RyanKent James77 2 Replies Last reply Reply Quote 0
              • RyanKent
                RyanKent @James77 last edited by

                As Dave shared, the W3C is the official organization for determining the validity of code. Generally speaking, you want your code to be valid.

                If you want an area to be a click-able link try Maximise's suggestion.

                1 Reply Last reply Reply Quote 1
                • James77
                  James77 @James77 last edited by

                  Many thanks - I'm going to have a serious word with my coders!!

                  1 Reply Last reply Reply Quote 1
                  • 1 / 1
                  • First post
                    Last post
                  • Do you get penalized in search results when you use a heading tag, but it's not technically a heading (used for emphasis)?
                    MattRoney
                    MattRoney
                    0
                    4
                    95

                  • Is it ok to use H1 tags in breadcrumbs?
                    OlegKorneitchouk
                    OlegKorneitchouk
                    0
                    5
                    4.1k

                  • Does using data-href="" work more effectively than href="" rel="nofollow"?
                    Everett
                    Everett
                    0
                    3
                    18.1k

                  • What hosting companies do you use & do you use dedicated servers
                    ClaireH-184886
                    ClaireH-184886
                    0
                    5
                    297

                  • Should I be using use rel=author in this case?
                    AlanBleiweiss
                    AlanBleiweiss
                    0
                    2
                    427

                  • OK to block /js/ folder using robots.txt?
                    katemorris
                    katemorris
                    0
                    4
                    2.3k

                  • Is it ok to just use the end of the url when using a Rel Cononical Link?
                    rhutchings
                    rhutchings
                    0
                    2
                    658

                  • Will using hidden divs cause me problems?
                    alexhoug
                    alexhoug
                    0
                    2
                    814

                  Get started with Moz Pro!

                  Unlock the power of advanced SEO tools and data-driven insights.

                  Start my free trial
                  Products
                  • Moz Pro
                  • Moz Local
                  • Moz API
                  • Moz Data
                  • STAT
                  • Product Updates
                  Moz Solutions
                  • SMB Solutions
                  • Agency Solutions
                  • Enterprise Solutions
                  • Digital Marketers
                  Free SEO Tools
                  • Domain Authority Checker
                  • Link Explorer
                  • Keyword Explorer
                  • Competitive Research
                  • Brand Authority Checker
                  • Local Citation Checker
                  • MozBar Extension
                  • MozCast
                  Resources
                  • Blog
                  • SEO Learning Center
                  • Help Hub
                  • Beginner's Guide to SEO
                  • How-to Guides
                  • Moz Academy
                  • API Docs
                  About Moz
                  • About
                  • Team
                  • Careers
                  • Contact
                  Why Moz
                  • Case Studies
                  • Testimonials
                  Get Involved
                  • Become an Affiliate
                  • MozCon
                  • Webinars
                  • Practical Marketer Series
                  • MozPod
                  Connect with us

                  Contact the Help team

                  Join our newsletter
                  Moz logo
                  © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                  • Accessibility
                  • Terms of Use
                  • Privacy