Skip to content

Neutralize link styles for placeholder links/named anchors #19411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2016
Merged

Neutralize link styles for placeholder links/named anchors #19411

merged 1 commit into from
Mar 5, 2016

Conversation

patrickhlauke
Copy link
Member

Fixes #19402

@patrickhlauke patrickhlauke added this to the v4.0.0-alpha.3 milestone Mar 5, 2016
patrickhlauke added a commit that referenced this pull request Mar 5, 2016
Neutralize link styles for placeholder links/named anchors
@patrickhlauke patrickhlauke merged commit 40c81c2 into twbs:v4-dev Mar 5, 2016
@mdo mdo mentioned this pull request Mar 5, 2016
@abstractic
Copy link

abstractic commented May 10, 2016

If a clickable element have the same style and behaviour as a normal link (as in this case, as I assume that we still want it to be a link, or we should use a button), then we're keeping commonly known UX design patterns in the visual aspect of clickability, which is a way better UX approach than removing or change the default styling.

https://www.nngroup.com/articles/clickable-elements/

@patrickhlauke
Copy link
Member Author

patrickhlauke commented May 10, 2016

default styling (in browsers) for anchors which lack an href is not to have an underline/link color. links without href do not behave as a normal link, as they can't be focused/activated with the keyboard. i'll revisit the styling to see if I can include further qualifiers (e.g. to let links without href, but with a tabindex and role attribute, receive the regular styling), but beyond that the rationale here still stands.

@abstractic
Copy link

abstractic commented May 10, 2016

Oh sorry, I was referring more to the issue here #19402 (comment), as I think it will be easier for each individual developer to add their own style on placeholder links, than forcing everyone to do pointless overrides of the a:not([href]) {} styling.

For your information, the default link behaviour is way easier to override than the a:not([href]) {}, which requires a developer to write a name pattern like a.myclass:not([href]) { [my new color] } and a.myclass:not([href]):hover { [my new color] } to change a simple color.

@patrickhlauke
Copy link
Member Author

if you're using a link without href to trigger an action, it also needs to be keyboard focusable (using at least tabindex=0) and expose a correct role to assistive technologies (using role=button, for instance). otherwise keyboard users and assistive tech users will not be able to correctly use it/use it at all. once i extend the selector(s) to also cover these cases, there won't be a need for authors to do "pointless overrides", but instead there will be a need to do "the right thing".

@abstractic
Copy link

abstractic commented May 10, 2016

Yes, that is correct, but I think we're misunderstanding each other about the styling and override options that are available, once the :not([href]) selector is declared.

The :not([href]) selector strictly tells the browser that an anchor without the HREF attribute <a class="myclass" role="button">action</a>, should use the inherited color and text decoration (in this case BODY assigned attributes), so when a developer writes anything like this:

.myclass {

    color: blue;

    &:hover {

        text-decoration: underline;
        color: blue;
    }
}

It get ignored by the browser, and the developer is forced to write the following for it to be overridden:

.mytest:not([href]) {

    color: blue;

    &:not([href]):hover {

        text-decoration: underline;
        color: blue;
    }
}

@patrickhlauke
Copy link
Member Author

@abstractic thanks, that makes your specific problem a bit clearer now. With #19874 you should be able to simply add tabindex=0 (which will also now make that action keyboard-focusable and operable, which it currently isn't), i.e. <a class="myclass" tabindex="0" role="button">action</a>

@abstractic
Copy link

You're welcome. I'm glad to help out.

xi pushed a commit to xi/mfbs that referenced this pull request Jul 14, 2016
See twbs/bootstrap#19411 for reference

Having different styles for <a> with and without href is the default
browser behavior.

We could also do link styling on a[href], but that would be hard to
overwrite.

The downside of this solution is that it is now hard to overwrite
a:not([href]), but that is a much less common task.
EricDunsworth added a commit to EricDunsworth/wet-boew that referenced this pull request Sep 9, 2016
Also prevented contrast ratio issues in pagination placeholder links that use the "active" class.

Related to twbs/bootstrap#19402 and partially-based on twbs/bootstrap#19411 (thanks @patrickhlauke).
jvanulde pushed a commit to jvanulde/wet-boew that referenced this pull request Dec 29, 2016
Also prevented contrast ratio issues in pagination placeholder links that use the "active" class.

Related to twbs/bootstrap#19402 and partially-based on twbs/bootstrap#19411 (thanks @patrickhlauke).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants