Is using a Href in Div OK?
-
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 2Is 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>
However I would assume a search engine is smart enought to know its the same thing???
Thanks
-
Many thanks - I'm going to have a serious word with my coders!!
-
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.
-
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!!
-
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.
-
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.
-
Neither option is valid HTML. Browser behavior and crawler behavior would be unpredictable.
The code would be something like:
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Href lang issues - help needed!
Hi, I have an issue with Google indexing the US version of our website rather than the UK version on Google.co.uk. I have added hreflang tags to both sites (https://www.pacapod.com/ and https://us.pacapod.com/), have updated and submitted an XML sitemap for each website and checked that the country targeting in search console is set-up correctly but Google are still indexing the wrong website. I would be grateful for any assistance with this issue. Many thanks Eddie
Technical SEO | | mypetgiftbox0 -
JSON-LD meta data: Do you have any rules/recommendations for using BlogPosting vs Article?
Dear Moz Community. I'm looking at moving from in-line Microdata in the HTML to JSON-LD on the web pages that I manage. Seems a far simpler solution having all the meta data in one place - especially for trouble shooting! With this in mind I've started to change the page templates on my personal site before I tackle the ones for my eCommerce site. I've made a start, and I'm still working on the templates producing some default values (like if a page doesn't have an associated image) but have been wondering if any of you have any rules/recommendations for using BlogPosting vs Article? I'd call this type of page an Article:
Technical SEO | | andystorey
https://cycling-jersey-collection.com/browse-collection/selle-italia-chinol-seb-bennotto-1982-team-jersey Whereas this page is from the /blog so that should probably be a BlogPosting:
https://cycling-jersey-collection.com/blog/2017-worldtour-team-jerseys I've used the following resources but it would be great to get a discussion on here.
https://yoast.com/structured-data-schema-ultimate-guide/
https://developers.google.com/search/docs/data-types/data-type-selector
https://search.google.com/structured-data/testing-tool/u/0/ I'm keen to get this 100% right as once this is done I'm going to drive through some further changes to get some progress on things like this: https://moz.com/blog/ranking-zero-seo-for-answers
https://moz.com/blog/what-we-learned-analyzing-featured-snippets Kind Regards andy moz-screenshot.jpg1 -
Changing permalinks in new wordpress website using regex in 301s?
Hi there I am working on a website and we would like to change the permalinks from product-category (replacing with Shop) and product to buy. Currently there are nearly 400 products and multiple categories. Although the website has just been indexed wondering if we need to do 301's? if we did would like to use regex to manage so redirect would be as example: mydomain.com/sub-domain/product-category/ redirecting to to mydomain.com/sub-domain/shop/ (I know you do not need to put in the domain but as an example) - could anyone give me the regex for this? Same for products: mydomain.com/sub-domain/product/sample-product redirect to mydomain.com/sub-domain/buy/sample-product thanks in anticipation
Technical SEO | | musthavemarketing0 -
Using a Colo Load Balancer to serve content
So this is a little complicated (at least for me...) We have a client who is having us rebuild and optimize about 350 pages of their website in our CMS. However, the rest of the website will not be on our CMS. We wanted to build these pages on a sub-domain that is pointed to our IPs so it could remain on our CMS--which the client wants. However, they want the content on a sub-directory. This would be fine but they will not point the main domain to us and for whatever reason this becomes impossible per their Dev team. They have proposed using a Colo Load Balancer to deliver the content from our system (which will be on the sub domain) to their sub directory. This seems very sketchy to me. Possible duplicate content? Would this be a sort of URL masking? How would Google see this? Has anyone ever even heard of doing anything like this?
Technical SEO | | Vizergy0 -
Custom hreflang tags in WP & using with Yoast
Hi My clients dev has added custom fields for adding hreflang tags to head of pages such as: "Rel Type", "The URL", and "Language Code" Am i right in thinking that until a different language/country version of the site is created these can remain empty or should they still be populated once added say with some sort of global reference or best left blank since will leave the head content global by default ? Also how important is it to add charset to the language code ? since seems optional ? Also this set up is on WP multi-site with Yoast and devs asked me the below: _One thing to note is that Yoast generates its own "canonical" tags - so if _
Technical SEO | | Dan-Lawrence
_you are going to use hreflang tags and canonical tags then you don't need to _
_add a canonical using the custom fields I have set up - Yoast has that _
sorted. _But if you are going down the route of NOT having any canonical tags - and _
_using a x-defult for the hreflang tags, I will need to try and suppress the _
_Yoast canonical tag so you can do this. Much depends on your approach and _
what you think is best. So how do i know if using canonicals or x-default, i take it best simplest to leverage Yoast and hence not add canonicals to custom fields ? Isnt x-default just for indicating language selectors/redirector not specific to 1 region? So long as havnt got those then good to proceed with Yoasts generated canonicals ? Cheers dan0 -
Missing Meta Tags - "thousands" using WooCommerce?
Recently took a site live for a client using WP/WooCommerce to replace their antiquated shopping cart site and have encountered thousands of "Missing Meta Description Tag" errors. Have researched and tried a couple different approaches, but nothing really seems to fix this problem. I'm happy to continue to research, but have never encountered this problem before. Anyone else encountered similar? If so, how did you fix? Which resources to start with? 2VKDRVx
Technical SEO | | twelvetwo.net0 -
What are the potential SEO downsides of using a service like unbounce for content pages?
I'm thinking of using unbounce.com to create some content driven pages. Unbounce is simple, easy-to-use, and very easy for non-devs at my company to create variations on pages. I know they allow adding meta descriptions, title tags, etc and allow it to be indexable by Google, but I was wondering if there were any potential downsides to using unbounce as opposed to hosting it myself. Any help would be appreciated!
Technical SEO | | Seiyav0 -
Using Thesis as blog platform vs. Tumblr
I read a lot of advantages by using Thesis as a platform for blogging, but I like the themes and other plugins from Tumblr. Are there equivalents at Tumblr to the Thesis benefits so I can go a head and go with Tumblr?
Technical SEO | | HyperOffice0