HTML nohref Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Links & Maps

Introduction

The nohref attribute is a boolean HTML attribute used on <area> elements inside a client-side image map. When present, that hotspot is not a hyperlink—clicks do not navigate. Image maps pair an <img usemap="#name"> with a <map> containing shaped regions. Some regions link with href; others are decorative or reserved for scripting. nohref was the HTML4 way to mark non-link regions. In HTML5 it is obsolete—omit href instead—but you will still encounter it in legacy tutorials and code.

What You’ll Learn

01

Boolean attr

Present = no link.

02

area only

Image map hotspots.

03

+ usemap

Client-side maps.

04

vs href

Link or not.

05

HTML5 way

Omit href.

06

JS toggle

removeAttribute.

Purpose of nohref Attribute

The primary purpose of nohref is to define image-map regions that should not navigate when clicked. A diagram might label sections visually while only some labels are actual links. Without nohref (or without omitting href in HTML5), an <area> with a missing or empty href could behave inconsistently in very old browsers—hence the legacy attribute.

Today, client-side image maps with usemap, <map>, and <area> are less common than CSS layouts or SVG links, but they remain valid for diagrams and infographics. Understanding nohref helps you read older markup and choose the correct modern pattern for non-interactive hotspots.

⚠️
Obsolete in HTML5

Do not use nohref in new projects. Write <area shape="…" coords="…" alt="…"> without href for non-clickable regions. In JavaScript, use removeAttribute("href") rather than setAttribute("nohref", "").

📝 Syntax

Add the boolean nohref attribute to an <area> inside a <map>:

nohref.html
<img src="diagram.png" alt="Site navigation diagram" usemap="#site-map">



<map name="site-map">

  <area shape="rect" coords="10,10,120,80" href="/html" alt="HTML section">

  <area shape="rect" coords="130,10,240,80" nohref alt="CSS label (decorative)">

</map>

Syntax Rules

  • Boolean attribute—write nohref alone; presence means no navigation.
  • Valid only on <area> elements inside <map>.
  • Requires shape, coords, and descriptive alt like any area.
  • Mutually exclusive with a working link: do not combine nohref and href on the same area.
  • HTML5 equivalent: omit href entirely on non-clickable areas.
  • Dynamic disable: area.removeAttribute("href") in JavaScript (preferred over adding nohref).

💎 Values

The nohref attribute is boolean—it has no meaningful string value:

  • nohref — Attribute present; area is not a hyperlink.
  • nohref="" — Also valid in HTML; same as bare nohref.
  • Attribute absent — Area may link if href is set; otherwise behaves as non-navigating in HTML5.
  • Modern HTML5: no href and no nohref — preferred non-link pattern.
nohref-js.html
const area = document.getElementById("hotspot");

// Disable link (modern)
area.removeAttribute("href");

// Re-enable link
area.setAttribute("href", "/destination");

⚡ Quick Reference

Use caseMarkupNotes
Clickable hotspot<area href="..." alt="...">Normal link region
Non-clickable (HTML5)<area alt="..."> (no href)Preferred today
Non-clickable (legacy)<area nohref alt="...">HTML4 pattern
Disable via JSarea.removeAttribute("href")Dynamic off
Enable via JSarea.setAttribute("href", url)Dynamic on
Image linkusemap="#map-name" on imgClient-side map

Applicable Elements

ElementSupported?Notes
<area>YesOnly element for nohref
<map>NoContainer; use on child areas
<img>NoUses usemap, not nohref
<a>NoUse absence of href or href="#" patterns differently

nohref vs omitting href vs href

ApproachExampleWhen to use
With link<area href="/page" alt="Go">Clickable hotspot
HTML5 non-link<area alt="Label only">New projects (preferred)
Legacy non-link<area nohref alt="Label only">Reading or maintaining old HTML

Examples Gallery

Image map with a linked HTML region and a non-clickable CSS region, JavaScript href toggling, and HTML5 vs legacy markup.

👀 Live Preview

Click the HTML region to follow the link. The CSS region uses nohref and does not navigate:

Navigation diagram — HTML links, CSS region is non-clickableLearn HTMLCSS label (decorative, no link)

Top region: clickable. Bottom region: nohref blocks navigation.

Example — Clickable and Non-Clickable Areas

One linked region and one region marked with nohref:

map-nohref.html
<img src="diagram.png" alt="Navigation diagram" usemap="#image-map">



<map name="image-map">

  <area shape="rect" coords="253,98,111,1" href="/html/tags/a" alt="Learn HTML">

  <area shape="rect" coords="253,250,74,148" nohref alt="CSS label (no link)">

</map>
Try It Yourself

How It Works

The first <area> includes href and acts as a normal link. The second includes nohref, so the browser treats that pixel region as non-navigating while still part of the map geometry.

Dynamic Values with JavaScript

Disable a hotspot by removing href rather than adding nohref:

dynamic-nohref.html
<area id="dynamicArea" shape="rect" coords="253,98,111,1" href="/html/tags/a" alt="Learn HTML">



<script>

  function disableLink() {

    document.getElementById("dynamicArea").removeAttribute("href");

  }

  function enableLink() {

    document.getElementById("dynamicArea").setAttribute("href", "/html/tags/a");

  }

</script>
Try It Yourself

How It Works

Removing href achieves the same effect as nohref in modern browsers. Restoring href re-enables navigation. Avoid dynamically setting nohref in new scripts.

Example — HTML5 vs Legacy Markup

The modern equivalent of nohref is simply omitting href:

modern-area.html
<!-- HTML5 (preferred) -->

<area shape="rect" coords="253,250,74,148" alt="Decorative label">



<!-- Legacy HTML4 -->

<area shape="rect" coords="253,250,74,148" nohref alt="Decorative label">
Try It Yourself

How It Works

HTML5 defines that an <area> without href is not a hyperlink. The nohref attribute remains for backward compatibility but is not required for new documents.

♿ Accessibility

  • alt on every area — Describe each region, including non-link areas marked with nohref or without href.
  • Meaningful img alt — The image should describe the overall diagram, not just “image map.”
  • Keyboard focus — Only linked areas appear in the tab order; non-link regions are skipped (expected behavior).
  • Don’t rely on maps alone — Provide a text list of links below complex diagrams when possible.
  • Consider simpler patterns — For interactive UI, regular links or buttons are often more accessible than dense image maps.

🧠 How nohref Works

1

Image links to map

img usemap="#name" connects to map.

usemap
2

Areas define regions

shape and coords outline each hotspot.

area
3

nohref blocks link

Area present but href navigation disabled.

nohref
=

Selective interactivity

Some regions link; others do not.

Browser Support

The nohref attribute is recognized in all major browsers on <area> elements for legacy compatibility. HTML5 validators flag it as obsolete. Omitting href is the standards-based approach and works consistently in modern browsers.

HTML5 · Fully supported

Broad nohref compatibility

All major browsers support the nohref attribute in production use.

98% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer IE 9+ supported
Full support
Opera Fully supported
Full support
nohref attribute 98% supported

Bottom line: Browsers still honor nohref in old pages; write new maps without href instead of nohref.

💡 Best Practices

✅ Do

  • Prefer omitting href — Use HTML5 non-link areas instead of nohref in new code.
  • Keep alt text meaningful — Non-clickable regions still need descriptive alt values.
  • Test the full map — Verify which regions navigate and which do not across browsers.
  • Use removeAttribute in JS — Toggle links by adding or removing href, not by toggling nohref.
  • Consider alternatives — SVG links, CSS overlays, or plain anchor lists may be easier to maintain.

❌ Don’t

  • Pair with coords and shape — Every area needs correct geometry; see the coords attribute guide.

Conclusion

The nohref attribute marks <area> hotspots that should not navigate in client-side image maps. It is a simple boolean legacy feature from HTML4.

Modern HTML achieves the same result by omitting href. Learn nohref to understand older tutorials and codebases, but apply current best practices when building new pages.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about nohref

Bookmark these before your next nohref implementation.

5
Core concepts
🚫 02

Blocks links

Boolean nohref.

Behavior
📝 03

Omit href

HTML5 preferred.

Modern
⚙️ 04

JS toggle

removeAttribute.

Dynamic
05

alt always

Link or not.

A11y

❓ Frequently Asked Questions

It marks an <area> in an image map as non-clickable. The region exists in the map but does not navigate.
<area> only, inside a <map> used with usemap on an <img>.
It is obsolete. Browsers still support it for legacy pages. New code should omit href instead.
Call area.removeAttribute("href"). Restore with setAttribute("href", url). Avoid setAttribute("nohref", "") in new scripts.
nohref is an explicit legacy boolean attribute. Omitting href is the HTML5 way to define a non-link area. Both prevent navigation in practice.
Yes. Provide meaningful alt on every <area>, whether or not it links.

Mark non-clickable map regions

Practice image maps with nohref, href toggling, and HTML5 omit-href patterns in the Try It editor.

Try image map example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful