Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it valid HTML to have an anchor tag without href and without name?

Is it valid HTML to have an anchor tag without href and without name? In our app we have some delete links which are disabled (hence no href attribute), but still shown to the user.


I am posting this question on behalf of Joshua Muheim which was asked in the comments of a related question. It is very similar to the original question, but different enough that I felt it was worthwhile to open it as a separate question.

like image 262
zzzzBov Avatar asked Apr 30 '13 14:04

zzzzBov


People also ask

Is href mandatory for a tag?

The tag is fine to use without an href attribute. Contrary to many of the answers here, there are actually standard reasons for creating an anchor when there is no href. Semantically, "a" means an anchor or a link. If you use it for anything following that meaning, then you are fine.

Which are the valid HTML anchor tags?

<a>: The Anchor element. The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.

Can anchor tag have name?

An anchor name is the value of either the name or id attribute when used in the context of anchors. Anchor names must observe the following rules: Uniqueness: Anchor names must be unique within a document. Anchor names that differ only in case may not appear in the same document.

Does hyperlink require name attribute in the anchor tag?

You can create a link to a named anchor by using the name attribute (or the id attribute).


1 Answers

Yes it's valid, the HTML spec says:

If the a element has no href attribute, then the element represents a placeholder for where a link might otherwise have been placed, if it had been relevant, consisting of just the element's contents.

like image 57
zzzzBov Avatar answered Sep 22 '22 03:09

zzzzBov