HTML Thing… Label versus Div or Span When it Comes to Inputs

One of the things that PyCharm tells me over and over again when it comes to HTML and Inputs is that I’m just not using those ——- — labels you —- ——- excuse for a ——- programmer. (Ok, so I might be paraphrasing a bit) Now for the most part it isn’t the end of days if you use a span or div instead. No kittens will be harmed either way. However, and I admit I must be slow for not seeing this, but labels do have one advantage as told by the dub see three:

The label element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if the user clicks on the text within the label element, it toggles the control.

Quite simple put, if the user clicks the label or the input, it will put focus on the input. Yeah so not earth shattering but for people with stupid hands like me, it just gives me a better chance of actually clicking a textbox than the massive Evony Online ad right next to it.

2 thoughts on “HTML Thing… Label versus Div or Span When it Comes to Inputs”

  1. Also, you can click the label of a checkbox/radio to check/uncheck it. More importantly, for those that use screen readers, having a label for an input tells them what the input is for.

Comments are closed.