HTMHell supports Black Lives Matter. ✊🏾 Code is always political.

#14 not my type

submitted on by Manuel

Bad code Bad code

<a type="button" class="button" href="/signup" tabindex="-1">Sign up</a>

Issues and how to fix them Issues and how to fix them

  1. The type attribute has no effect on the semantics of an <a> element.
  2. An anchor may have the type attribute, but the value should be a valid MIME type. Browsers may consider it, but it’s purely advisory.
  3. If the presence of the href attribute makes sense, you most definitely want to use a proper link (<a>) and not a button, no matter how the element looks like in your design.
  4. A negative tabindex value means that the element is not accessible via keyboard, but it could be focused with Javascript.
  5. Do not change native semantics, unless you really have to.
  6. If you need a button, use the <button> element.

Good code Good code

<a href="/signup" class="button">Sign up</a>