Content · Web Development · HTML

HTML Avoiding Empty and JavaScript Links

An anchor without a real destination is not a useful navigation link. href="#" often jumps to the top and may confuse users, while javascript: URLs mix behavior into markup.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

An anchor without a real destination is not a useful navigation link. href="#" often jumps to the top and may confuse users, while javascript: URLs mix behavior into markup. The important question is always where the link leads and whether the person reading the page can predict it.

What You Need to Know


Use a real a element for navigation and a button for an action. Provide a working destination instead of a visual imitation.

Links are the pathways through a website. The words on a link should help someone choose where to go before clicking it.

Example: See It in Action


Take a look at this small piece of HTML. You can use it in a practice document and change the text to make it your own.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<a href="registration.html">Register now</a>
<button type="button" id="open-info">More details</button>
<p>A real link needs a useful destination.</p>

Let’s Understand the Example


  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • Button is a real keyboard-accessible control. Inside a form, specify type when you do not want the default submit action.
  • A p groups a paragraph of related text. Start another paragraph for a new thought.
  • Href contains the destination of a link. A value starting with # points to an id on the same page.
  • Type changes the kind of input, script, resource or button, depending on the element.
  • Id gives one element a unique name within the page, so a link, label, or script can point to it.

The first example link points to registration.html. Check whether that destination exists relative to the document. A link changes where readers go; it does not perform an action such as saving a form.

What Should You See?


You should see a link named “Register now”. Selecting it leads to registration.html when that destination exists. Try it with the mouse and the keyboard.

Imagine this link is read out of context. Would its text still explain the destination? Rename unclear links before trying to make them look nicer with CSS.

Try It Yourself


  1. Replace a fake action link with a real button.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Writing href="#" just to give text an underline and pointer cursor.
  • Avoid dead links, empty href values and clickable-looking text without a real destination.

Key Takeaways


  • An anchor without a real destination is not a useful navigation link. href="#" often jumps to the top and may confuse users, while javascript: URLs mix behavior into markup.
  • An a element becomes a working link when it has an href. Its visible text should tell readers where they will go.
  • Use a real a element for navigation and a button for an action. Provide a working destination instead of a visual imitation.
Share this resourceSend this page to someone who may find it useful.