top | item 39988274

(no title)

moistness | 1 year ago

Judging by people who make links via click listener on DIV, the answer is no.

On one side it’s understandable that people work more on abstractions and are more productive (e.g. learn React first, then maybe understand how P is different from DIV), on the other side it’s incredibly frustrating to see links that aren’t real links even on Google’s websites.

discuss

order

friendzis|1 year ago

> people work more on abstractions and are more productive

Well, that's one way to define "productive". If a site contains links that are "clickable divs" or has layout shifts, or whatever other "modern" atrocity, can the work really be rated as "done"?

Without done work, productivity is either zero, or undefined.

LeafItAlone|1 year ago

> Judging by people who make links via click listener on DIV, the answer is no.

Backend dev that dabbles in front end here. What’s the problem with this?

extra88|1 year ago

It's reinventing what browsers can already do if you use an HTML link <a href="…"> so it's inefficient. It's also inaccessible.

* It's not in the focus order so you can't keyboard navigate to it. You have to add tabindex="0" to the div to correct that. * It's not keyboard operable. You have to add not just a click listener but also a key press event listener and check that the key pressed is Enter. * It has no role so a screen reader user doesn't know that it's a link. You have to add role="link" to it.

It's also missing useful user experience features of actual links

* You can hover a cursor over a real link to see the destination URL in the status bar. * You can copy a real link's URL. * You can use alternate clicks or a contextual menu to open a link destination in a new window.

Search engines can't find and index the destination of fake links.

moistness|1 year ago

HTML means HyperText Markup Language. HyperText means “documents linked to each other”. By not using <A> you’re skipping the core reason why HTML exists, as defined by its name.

The other comment explains pretty well what that causes in the browser.