0

Why should we not use <a><li>something</li></a>? or something like <a><div>something2</div></a>?

isherwood
  • 58,414
  • 16
  • 114
  • 157
  • Do you have a source where it is stated that we shouldn't? – Cœur Jan 23 '19 at 17:50
  • Software development is already hard enough. Opting out from useful tools (such as HTML linters) and relying on all browsers applying the same fixes for invalid code is not going to help. – Álvaro González Jan 23 '19 at 17:51
  • This sort of thing was discouraged (though still common) in html4; but it's no longer Considered Harmful. – Daniel Beck Jan 23 '19 at 17:52
  • @DanielBeck - A check using NVDA with Firefox shows that `
  • something
  • ` is indeed harmful. The list items are not identifiable to NVDA users. – Alohci Jan 23 '19 at 18:02
  • @Alohci fair point -- I was speaking to the general case of block-level elements within an anchor tag; isherwood's answer below explains the specific case of `li` (which is due to nesting rules for list items, not the anchor itself afaik.) – Daniel Beck Jan 23 '19 at 18:15