In the context of HTML forms, why are label elements important for accessibility and usability?

Label elements are important for accessibility and usability in HTML forms because they provide a clear association between form inputs and their labels. This association is crucial for users who rely on screen readers or other assistive technologies to navigate and interact with web content. Without proper labels, these users may have difficulty understanding the purpose of form inputs, leading to confusion and frustration. By using label elements correctly, developers can ensure that all users, regardless of their abilities, can easily understand and interact with form elements.

<form action="/submit-form.php" method="post">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username">
  
  <label for="password">Password:</label>
  <input type="password" id="password" name="password">
  
  <input type="submit" value="Submit">
</form>