Highlighted

Safe to use empty <a> tags in 2019?

Contributor ,
May 13, 2019

Copy link to clipboard

Copied

What's the latest on how naughty (or not) it is to use empty <a> tags?

I like using <a> for almost everything cosmetically interactive; keeping all my formatting is in the CSS. And the visual is often a background image. As such, my HTML has various instances that look like <a class="name"></a> with nothing else, not even the usual space (or nbsp) we used to have to put to make it work.

Is this bad practice in 2019, or is it relatively safe to use empty <a> tags nowadays?

(I just find the code looks better without it if it doesn't need it.)

Adobe Community Professional
Correct answer by Nancy OShea | Adobe Community Professional

I don't know what you mean by safe.  What are your concerns exactly?  Safe to use security-wise, browser-wise or search engine-wise?  All could be impacted.

Named anchors were supported in HTML4 doc types and dropped from the HTML5 specs.   So the type of document you use matters. 

You can read all about anchor tags on the MDN site.   Security issues are covered about half way down the page.  The browser compatibility chart is shown towards the end.

<a>: The Anchor element - HTML: Hypertext Markup Language | MDN

SEO MOZ   What Are Internal Links

Views

208

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Safe to use empty <a> tags in 2019?

Contributor ,
May 13, 2019

Copy link to clipboard

Copied

What's the latest on how naughty (or not) it is to use empty <a> tags?

I like using <a> for almost everything cosmetically interactive; keeping all my formatting is in the CSS. And the visual is often a background image. As such, my HTML has various instances that look like <a class="name"></a> with nothing else, not even the usual space (or nbsp) we used to have to put to make it work.

Is this bad practice in 2019, or is it relatively safe to use empty <a> tags nowadays?

(I just find the code looks better without it if it doesn't need it.)

Adobe Community Professional
Correct answer by Nancy OShea | Adobe Community Professional

I don't know what you mean by safe.  What are your concerns exactly?  Safe to use security-wise, browser-wise or search engine-wise?  All could be impacted.

Named anchors were supported in HTML4 doc types and dropped from the HTML5 specs.   So the type of document you use matters. 

You can read all about anchor tags on the MDN site.   Security issues are covered about half way down the page.  The browser compatibility chart is shown towards the end.

<a>: The Anchor element - HTML: Hypertext Markup Language | MDN

SEO MOZ   What Are Internal Links

Views

209

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 13, 2019 0
Adobe Community Professional ,
May 13, 2019

Copy link to clipboard

Copied

I don't know what you mean by safe.  What are your concerns exactly?  Safe to use security-wise, browser-wise or search engine-wise?  All could be impacted.

Named anchors were supported in HTML4 doc types and dropped from the HTML5 specs.   So the type of document you use matters. 

You can read all about anchor tags on the MDN site.   Security issues are covered about half way down the page.  The browser compatibility chart is shown towards the end.

<a>: The Anchor element - HTML: Hypertext Markup Language | MDN

SEO MOZ   What Are Internal Links

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 13, 2019 1
Adobe Community Professional ,
May 13, 2019

Copy link to clipboard

Copied

In HTML5, the <a> tag is always a hyperlink, but if it has no href attribute, it is only a placeholder for a hyperlink. If you want to use it for other purposes, you must assign an Aria role as per MDN document that Nancy has pointed to.


Ben

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 13, 2019 1