Html

Using href links inside option tag

27 September 2026 · 7 min read

Using href links inside option tag

Navigating the web should be a seamless experience, yet sometimes developers face unique challenges when trying to implement specific user interface behaviors. One such common question revolves around the feasibility of using href links inside the <option> tag within a standard HTML

The Core Challenge: Why href in <option> Isn’t Standard

The HTML specification defines the

This limitation stems from the fundamental semantics of HTML. An

Understanding HTML Semantics

Semantic HTML is about using elements for their intended purpose. A

Browser Interpretation

When browsers encounter invalid HTML, they engage in error recovery. For instance, if you write , most browsers will strip out the tag and render only the text “Go to Page” as a selectable option. The hyperlink functionality will be lost entirely. This inconsistent rendering and the lack of a standardized way to handle such invalid markup make using href links inside the

The JavaScript Solution: Enabling Dropdown Navigation

While directly embedding href in

This technique separates concerns effectively: HTML handles the structure and options, while JavaScript manages the dynamic behavior and navigation. This separation makes the code cleaner, easier to maintain, and more predictable. Modern web development heavily relies on such patterns to create interactive and responsive user interfaces without violating core HTML principles. Developers often pair this with progressive enhancement strategies, ensuring basic functionality even if JavaScript is disabled, though navigation via dropdown typically requires JavaScript.

  1. Structure Your HTML: Create your
    
     </option></select>
    
  2. Add JavaScript Event Listener: Use JavaScript to select the element clearly with a

    • Label Your Select Element: Always associate a

      
       </select></label>
      
    • Provide a Default, Non-Navigating Option: Include an initial

    • Consider a “Go” Button: For better control, especially for keyboard and screen reader users, instead of immediate navigation on change, provide a separate “Go” button. The JavaScript would then trigger Question & Answer :
      I have the following HTML code:

      <select name="forma"> <option value="Home">Home</option> <option value="Contact">Contact</option> <option value="Sitemap">Sitemap</option> </select> 
      

      How can I make Home, Contact and Sitemap values as links? I used the following code and as I expected it didn’t work:

      <select name="forma"> <option value="Home"><a href="home.php">Home</a></option> <option value="Contact"><a href="contact.php">Contact</a></option> <option value="Sitemap"><a href="sitemap.php">Sitemap</a></option> </select> 
      

      UPDATE 2022: This answer is fine but really in 2022 we shouldn’t be doing this anymore!

      UPDATE (May 2020): Someone asked in the comments why I wouldn’t advocate this solution. I guess it’s a question of semantics. I’d rather my users navigate using <a> and kept <select> for making form selections because HTML elements have semantic meeting and they have a purpose, anchors take you places, <select> are for picking things from lists.

      Consider, if you are viewing a page with a non-traditional browser (a non graphical browser or screen reader or the page is accessed programmatically, or JavaScript is disabled) what then is the “meaning” or the “intent” of this <select> you have used for navigation? It is saying “please pick a page name” and not a lot else, certainly nothing about navigating. The easy response to this is well i know that my users will be using IE or whatever so shrug but this kinda misses the point of semantic importance.

      Whereas a funky drop-down UI element made of suitable layout elements (and some js) containing some regular anchors still retains it intent even if the layout element is lost, “these are a bunch of links, select one and we will navigate there”.

      Here is an article on the misuse and abuse of <select>.

      ORIGINAL ANSWER

      <select name="forma" onchange="location = this.value;"> <option value="Home.php">Home</option> <option value="Contact.php">Contact</option> <option value="Sitemap.php">Sitemap</option> </select> 
      

      UPDATE (Nov 2015): In this day and age if you want to have a drop menu there are plenty of arguably better ways to implement one. This answer is a direct answer to a direct question, but I don’t advocate this method for public facing web sites.