question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dealing with styling of "a" tags (with or without hrefs?)

See original GitHub issue

A very common markup in Angular version of bootstrap directives goes like this: <a (click)="prev()">Previous</a>

Pure bootstrap version would have an “empty” href (<a (click)="prev()" href="#">Previous</a>) to provide appropriate styling (cursor) but this is not needed in ng-version and can interfere with routing.

The question: how do we deal with this situation? Few ideas:

Now, I must admit that I don’t know what is the impact of removing href on accessibility and keyboard navigation, so the encapsulated CSS path might be a non-option in the end…

Thoughts?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:41 (27 by maintainers)

github_iconTop GitHub Comments

16reactions
pkozlowski-opensourcecommented, Jul 10, 2016

OK, another idea. How about this:

  • we add empty href (this gives us proper cursor and accessibility)
  • we call prevent default / stop propagation in a click handler.

To avoid pain of writing too much for prevent default we could use this trick: <a href (click)="!!doSth()">. Taken from https://github.com/angular/angular/issues/2042#issuecomment-105689213

9reactions
mendezacommented, Apr 6, 2016

This is what we do at Thomson Reuters: <a (click)="prev()" href>Previous</a> The href, even when truly empty like this, keeps the anchor focusable and in tabindex. This is essential for A11y.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styling <a> without href attribute - html - Stack Overflow
1 Answer 1 ; :not([href]) { /* Styles for anchors without href */ } ; { /* Styles for anchors with and without...
Read more >
Styling links - Learn web development | MDN
Link states​​ These can be styled using different pseudo-classes: Link: A link that has a destination (i.e., not just a named anchor), styled...
Read more >
How to style an anchor tag with no href attribute? - Misc
In this post, you will learn how to style an HTML anchor tag without href attribute with a demo and HTML-CSS codes.
Read more >
When (and when not to) use an anchor tag? - CSS-Tricks
If the a element has no href attribute, then the element represents a placeholder for where a link might otherwise have been placed,...
Read more >
HTML Button Link Code Examples – How to Make HTML ...
We can add a class to the anchor tag and then use that class selector to style the element. <a class="fcc-btn" href ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found