Is a link to links required?

I ask about this because I have some links that act like buttons that pull content through ajax, so I don't need any hrefs.

(I ask this from an SEO perspective)

+7
source share
8 answers

Is a link to links required?

Yes. Anchors without href attributes are not links.

I ask about this because I have links that act like buttons that pull content through ajax

If you do this, do it right. Use unobtrusive JavaScript and pushState .

"Links" that only work if you use a pointing device and have JS turned on are not good links.

I ask this from an SEO perspective

Search engines will not execute your JavaScript, so pseudo-links (which depend on JS) are just black holes of nothing, as much as possible).

+7
source

I assume that by β€œlinks” you simply mean the elements of a . If this is true, then:

Not. At least not in the HTML5 specification :

If the element a does not have the href attribute, then the element is a placeholder where the link could be placed otherwise if it were relevant.

From the HTML 4.01 specification :

Authors can also create an element A that does not indicate any anchors, i.e. which does not indicate href, name or id. Values ​​for these attributes can be set later through scripts.

+25
source

If you have links that act like buttons, you should probably use a <button> element.

+4
source

no no. But links may appear different (underline and color) if href is not installed.

+2
source

I'm not sure, but some time ago I had problems with "a" without href ... the clicks just didn't work. But perhaps it was just an old browser.

+2
source

According to the specifications, also you will find that browsers do not use different styles by default (for example, do not change the cursor to a pointer) when you leave href. The most common approaches to adding dummy hrefs are

 href="#" // But the event handler function must return false in order to avoid the default behaviour of jumping to the top of the page href="javascript:void()" // has the advantage of having no annoying default behaviour 
+2
source

They are not absolutely necessary, however you should probably put href="#/" as href to make it semantically correct. Without the href="" attribute href="" anchor is likely to be parsed as a bookmark on the page, especially if the name="" attribute is specified.

+1
source

While this is not required, you should add href to the anchor tags, because, well, without href, they are not anchor tags.

You can add '#' to the link and add onClick = 'return false;' to prevent a click event. If you use jQuery, you can add event.preventDefault() to your click handler for your links.

From an SEO perspective, I would use the use of headers for anchor tags (excluding the -ve text-indent property.)

0
source

All Articles