Skip to content
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

back-link is underlined when no href is provided #1171

Closed
penx opened this issue Feb 4, 2019 · 1 comment · Fixed by #1620
Closed

back-link is underlined when no href is provided #1171

penx opened this issue Feb 4, 2019 · 1 comment · Fixed by #1620
Labels
🕔 hours A well understood issue which we expect to take less than a day to resolve.
Milestone

Comments

@penx
Copy link

penx commented Feb 4, 2019

Consider the following HTML:

      <div>
        <a href="#">Standard anchor with href</a>
      </div>
      <div>
        <a>Standard anchor with no href</a>
      </div>
      <div>
        <a class="govuk-back-link" href="#">
          Back link with href
        </a>
      </div>
      <div>
        <a class="govuk-back-link">Back link with no href</a>
      </div>

https://codesandbox.io/s/4wylrj5w

Browser default behaviour is to underline anchors only when an href is provided. This is to ensure users can identify links on a page (an anchor without an href is not considered a link by default).

This feature also has the side effect of helping developers realise that they may have missed an href attribute - as they can visually see on the page that a link is not underlined.

The way the back-link is coded uses border-bottom instead of an underline, but this is not implemented as per normal anchor styles.

The old way browser default styles did this was as follows:

a[href] {
border-bottom: none
}

In newer browsers, the :any-link pseudo-selector can be used, though it has limited support
https://developer.mozilla.org/en-US/docs/Web/CSS/:any-link

I would recommend adding a[href] or ``:any-link` to the back-link component and wherever else you may be overriding anchor underline styles, so that you mirror browser default behaviour for anchors, help users identify links and help developers identify errors.

@NickColley
Copy link
Contributor

NickColley commented Feb 4, 2019

Hey @penx :)

It seems useful to be able to see when you mistakenly did not put a href by being consistent with regular links...

I think we would move the border-bottom styling into a selector like so:

.govuk-back-link[href] {
    // Use border-bottom rather than text-decoration so that the arrow is
    // underlined as well.
    border-bottom: 1px solid govuk-colour("black");
    text-decoration: none;
}

@kellylee-gds kellylee-gds added submitted-by-user 🕔 hours A well understood issue which we expect to take less than a day to resolve. and removed awaiting triage Needs triaging by team labels Feb 6, 2019
NickColley added a commit that referenced this issue Oct 25, 2019
"Browser default behaviour is to underline anchors only when an href is provided. This is to ensure users can identify links on a page (an anchor without an href is not considered a link by default).

This feature also has the side effect of helping developers realise that
they may have missed an href attribute - as they can visually see on the
page that a link is not underlined."

Fixes #1171
@36degrees 36degrees added this to the Next milestone Nov 7, 2019
m-green pushed a commit that referenced this issue Nov 13, 2019
"Browser default behaviour is to underline anchors only when an href is provided. This is to ensure users can identify links on a page (an anchor without an href is not considered a link by default).

This feature also has the side effect of helping developers realise that
they may have missed an href attribute - as they can visually see on the
page that a link is not underlined."

Fixes #1171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕔 hours A well understood issue which we expect to take less than a day to resolve.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants