Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-12-11 12:51:13

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Is href="#" still necessary?

We use <a href="#">...</a> in few places for links handled via js. Hovering such a link displays something like current/page/url# in the browser status bar, which is uselessly distracting and can hide the txp messagepane. Could we simply remove href from such links, replacing it with cursor: pointer css rule? IIRC, it bothered IE, but who cares nowadays?

Offline

#2 2023-12-11 13:23:56

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

Re: Is href="#" still necessary?

yes it is needed to make clickable in an accessible way (keyboard access, touch access, AT,…). Or you want to reimplement all that with JS?

<a>test string</a>is no different than <span>test string</span>

Try here to set focus on that element… (with the keyboard).

On the other hand, perhaps a <button /> would be more appropriate in some cases (e.g, close button on the message pane)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#3 2023-12-11 13:26:31

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,273
Website GitHub

Re: Is href="#" still necessary?

Apparently not (ironically the link there doesn’t seem to jump to the onclick_events section of the page I linked to – about 2/3 of the way down the page)

Not sure how relevant the discussion is, but the ancient stackoverflow page on the topic has alternatives like href="javascript:void(0);". But whether that then prevents JS from hooking into the anchor I’m unsure.

Last edited by Bloke (2023-12-11 13:29:09)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2023-12-11 13:31:27

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Re: Is href="#" still necessary?

phiw13 wrote #336097:

yes it is needed to make clickable in an accessible way (keyboard access, touch access, AT,…). Or you want to reimplement all that with JS?

Certainly not, but wouldn’t tabindex help in this case? Thanks for any hint.

Offline

#5 2023-12-11 13:36:23

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Re: Is href="#" still necessary?

phiw13 wrote #336097:

On the other hand, perhaps a <button /> would be more appropriate in some cases (e.g, close button on the message pane)

Yes, looks like a winner.

Offline

#6 2023-12-11 13:37:03

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

Re: Is href="#" still necessary?

Certainly not, but wouldn’t tabindex help in this case? Thanks for any hint.

That would, at best, make it eventually focusable. It doesn’t make it “clickable” (mous click, press return from keyboard, tap, etc).

As I said, consider using <button>, the MDN page Stef links to above suggest the same.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#7 2023-12-11 13:42:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,273
Website GitHub

Re: Is href="#" still necessary?

A button works for me for elements that aren’t actually hyperlinks.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2023-12-11 13:54:40

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Re: Is href="#" still necessary?

Buttons work great, but look like buttons :-) Seemingly, jQuery UI can help in my case (body/excerpt preview link), but I’d rather go vanilla way.

Offline

#9 2023-12-11 13:59:31

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,273
Website GitHub

Re: Is href="#" still necessary?

Phil has a CSS class for making buttons not look like buttons somewhere…


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#10 2023-12-11 14:00:54

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

Re: Is href="#" still necessary?

Please stay away from JQUI. It is not difficult to style a button: remove border, remove background…

<button class="txp-reduced-ui-button">close</a> (name TBD, see login panel, language select widget)

Last edited by phiw13 (2023-12-11 14:01:16)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#11 2023-12-11 14:23:16

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Re: Is href="#" still necessary?

Bloke wrote #336104:

Phil has a CSS class for making buttons not look like buttons somewhere…

Nope, can not find it.

phiw13 wrote #336105:

Please stay away from JQUI. It is not difficult to style a button: remove border, remove background…

We’d leave it with theme authors, then?

Offline

#12 2023-12-11 14:47:10

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,273
Website GitHub

Re: Is href="#" still necessary?

etc wrote #336106:

Nope, can not find it.

Drat. It’s the other way round. We have a class for making a link look like a button (navlink) that I was thinking of. Apologies. Though I’m sure if you ask him nicely he’ll add a class for the inverse ;)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB