bootstrap: Placeholder links (e.g. ...) shouldn't be styled as hyperlinks.
I’ve noticed that Bootstrap’s default CSS currently styles all a elements as hyperlinks (blue text color, underlining on mouse hover, etc…). Wouldn’t it make more sense to only style a elements that contain href attributes in that way?
The HTML 5.1 spec’s definition of the a element states that only a elements that use href attributes are considered to be hyperlinks. a elements that lack href are classified as placeholder links and are supposed to only consist of that element’s content. In other words, by default, placeholder links are meant to look like normal text without any special styling.
From what I can tell, all modern browsers’ built-in style sheets render placeholder links as normal text and only add colouring/underlining if an href attribute is used. Bootstrap 3 and 4 are currently overriding that behaviour.
JS Bin examples:
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 25 (16 by maintainers)
Commits related to this issue
- Neutralize link styles for placeholder links/named anchors — committed to twbs/bootstrap by patrickhlauke 8 years ago
- Bootstrap overrides: Changed placeholder links to look like plain text. Also prevented contrast ratio issues in pagination placeholder links that use the "active" class. Related to twbs/bootstrap#19... — committed to EricDunsworth/wet-boew by EricDunsworth 8 years ago
- Bootstrap overrides: Changed placeholder links to look like plain text. Also prevented contrast ratio issues in pagination placeholder links that use the "active" class. Related to twbs/bootstrap#19... — committed to jvanulde/wet-boew by EricDunsworth 8 years ago
- diff --git a/src/.DS_Store b/src/.DS_Store deleted file mode 100644 index 8a72164..0000000 Binary files a/src/.DS_Store and /dev/null differ diff --git a/src/css/bootstrap-reboot.css b/src/css/bootstr... — committed to ErikSeguinte/Zipf by ErikSeguinte 6 years ago
I honestly think this CSS snippet
a:not([href]) {}is a quite bad approach, as it will cause issues with override styling down the line, and the only way to override it, is to specify exactly the same name pattern likea.myclass:not([href]) { [my new color] }anda.myclass:not([href]):hover { [my new color] }or use the horrible bad!importantattribute.I think it’s better to remove the HREF attribute on actions that triggers a modal box or something similar, than using something like href=“#” or href=“javascript:void(0)”, which is way worse in a semantically correct perspective. A button would of course be the best solution, but it’s not always suitable.
With other words, this snippet causes more issues than good, and if I choose not to use a HREF attribute, I can also make sure that those specific anchors look like I want myself, instead of being forced to make ridiculous overrides of
a:not([href]) {}.So far this is the one of the only issues I can think of that has asked us to revisit this behavior. Given that, plus the higher specificity it introduces at a global level, there are no plans to change this in Bootstrap at this time.
As identified by @abstractic, this is causing us issues, we are having to exclude _reboot.scss in our projects to get links/buttons to style correctly as not all of them have [href]. Overwriting the property, or even using a global
aselector does not provide a fix.For us, links are often made using the
ui-sref="angular.route"orng-click="function()"attributes and certainly do not always contain thehrefattribute.We have no issue with it being by default un-styled if no link is present, but it should be configurable or improved, as I can fore-see quite a lot of people having similar issues to us.
It’s very possible I missed something, but why not
:linkto select<a>elements with workinghrefs? That way it only has the specificity of one “class”, which.btnand friends should be able to override.Small demo: http://codepen.io/tigt/pen/c032fa19010074d7fce6b8ed5de85809?editors=1100
We worked through this at GitHub to avoid the shitshow that @patrickhlauke mentioned. Here’s how we handle it in our Markdown styles: