What Should Be Avoided
In a navigation menu, dropdown menus are hidden using CSS. No script is provided for keyboard users to open the dropdown menu. As a result, users navigating with a keyboard will miss the elements within the dropdown. Sighted users can open the dropdown menu by mouse click or hover, but this functionality is not accessible to keyboard users. HTML Example (Incorrect implementation):
HTML/CSS
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Navigation Menu</title> <style> .dropdown-content { display: none; } .dropdown:hover .dropdown-content { display: block; } </style> </head> <body> <nav> <ul> <li><a href="#">Home</a></li> <li class="dropdown"><a href="#">Services</a> <ul class="dropdown-content"> <li><a href="#">Web Design</a></li> <li><a href="#">SEO</a></li> </ul> </li> <li><a href="#">Contact</a></li> </ul> </nav> </body> </html>
Explanation:In a navigation menu, dropdown menus are hidden using display:none. No script is provided for keyboard users to open the dropdown menu. As a result, users navigating with a keyboard will miss the elements within the dropdown. Sighted users can open the dropdown menu by mouse click or hover, but this functionality is not accessible to keyboard users.