Problem/Motivation

The styles we currently have for links changes the default text color to the blue one. But just a color change is not enough for some uses to differentiate normal text from links.

Proposed resolution

Add an underline to all links by default as it is defined on the Design System, and let it be overridden on specific situations if needed.

This means reversing the way CSS is currently arranged. Instead of removing underlines globally, and repairing them where needed, we will preserve the underline globally and remove it in cases where it is safe to do so.

CSS Before:

/* Remove underlines globally */
a, .link { text-decoration: none; }

/* Need to repair the underline. */
.messages a {  text-decoration: underline; }

/* Inherits global style, no underline. */
.tabs_link { }

CSS After:

/* Preserve link underlines globally. */
a, .link { }

/* Inherits global style, links underlined. */
.messages a { }

/* Tabs have distinct navigation group styling, safe to remove the underline. */
.tabs_link { text-decoration: none; }

Remaining tasks

  • Remove a, .link { text-decoration: none; } from elements.css
  • Update the global hover/focus styles, remove text-decoration: underline;.
  • Clean up any other text-decoration: underline; which are no longer necessary.
  • Identify any links where we can safely remove the underline because there is an alternative signifier (e.g. primary local tasks).

User interface changes

Links will be underlined from now on, as the global default style.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ckrina created an issue. See original summary.

Swapnil_Kotwal’s picture

Assigned: Unassigned » Swapnil_Kotwal
ckrina’s picture

Issue summary: View changes
FileSize
14.68 KB

Updating with the hover styles

andrewmacpherson’s picture

Issue summary: View changes

Thanks for filing this. I'm adding some demo code for the resolution.

Basically it means reversing the current CSS policy. Right now we are removing the underlines globally, then having to anticipate all the places where the underlines must be restored. But we'll never anticipate them all. Instead, it's safer to keep the link underlines globally, then remove them from places where we are confident that an alternative signifier has been provided (e.g. primary local tasks block).

The essential change here is removing the a, .link { text-decoration: none; } rule. I think it's a good idea to commit that change ASAP, then follow-up fixing the other instances where we do want to remove the underline. Are we OK with having multiple commits on the same issue?

Underlining links by default, for their resting state, means we can't use underlines as a focus style. So a:focus, .link:focus { text-decoration: underline; } needs to go too. That's why we were pushing for a focus style which surrounds the element on all 4 sides.

Hover styles are a nice bonus, but less essential because the pointer itself is the main signifier (mouse cursor, or actual fingertip). The proposal here for underlines to disappear on hover will work nicely when paired with the focus outline. So on hover the outline disappears, and the cursor changes to a hand icon. On focus, the underline is replaced by a 4-sides outline.

andrewmacpherson’s picture

andrewmacpherson’s picture

Priority: Normal » Major

WCAG 1.4.1 Use of Color is a level A success criterion, so bumping this to major. Specifically, it's about avoiding F73: Failure of Success Criterion 1.4.1 due to creating links that are not visually evident without color vision

Swapnil_Kotwal’s picture

@Cristina Chumillas (ckrina). I have uploaded a patch file for the issue. Kindly review.
I doubt it would work.

Kindly review.

fhaeberle’s picture

Status: Active » Needs review

Setting to NR because of patch.

fhaeberle’s picture

Assigned: Swapnil_Kotwal » Unassigned
Priority: Major » Normal

... and undo assignment and adjust priority, sorry.

andrewmacpherson’s picture

Priority: Normal » Major

Keep this at major please. The accessibility maintainers generally treat WCAG level-A issues as major.

andrewmacpherson’s picture

Status: Needs review » Needs work

@Swapnil_Kotwal - thanks for working on this.

I tried the patch from #7. Unfortunately it's a bit of a mess, so let's look at the problems:

  1. css/src/base/elements.css this is the biggest problem. The patch in #7 replaces the entire elements.css file with a patch file. So it's no longer a CSS file, instead it has lots of git information. This causes the Yarn CSS build commands to fail.

    There isn't a quick fix for this. I think the easiest thing to do would be to start again with this file, by resetting the changes and checking out a fresh copy.

  2. There are lots of indentation changes, which are unnecessary. For example:
     .messages a {
    -  color: var(--messages__link-color);
    -  text-decoration: underline;
    +    color: var(--messages__link-color);
     }
     
     .messages a:hover {
    -  color: var(--messages__link--hover-color);
    +    color: var(--messages__link--hover-color);
     }
     
     .messages pre {
    -  margin: 0;
    +    margin: 0;
     }
    

    We're only interested in the line which removes text-decoration: underline;. Drupal 8 ships with an .editorconfig file, to help us avoid indentation changes like this. Check to see it is working:

    • Lots of text editors and IDEs have support for .editorconfig, but some of them need a plugin for it. See https://editorconfig.org/
    • Check to see whether the .editorconfig file is missing from your development environment. It's a hidden file (name starts with a dot) so it sometimes gets missed when copying files.

Once these are dealt with, the patch file should be a lot simpler (and shorter).

charlieweb82’s picture

Status: Needs work » Needs review
FileSize
2.76 KB

Patch update remove the underline to links and focus

ckrina’s picture

Status: Needs review » Needs work

Thanks for working on this @charlieweb82! I've found some issues on the patch.

  1. +++ b/css/src/base/elements.css
    @@ -106,7 +104,7 @@ address {
     ins {
    -  text-decoration: underline;
    +  ¶
     }
    

    This is removing all the code inside the declaration. I think we shouldn't leave empty declarations, and specially extra spaces.

  2. +++ b/css/src/base/print.css
    @@ -10,7 +10,7 @@
       a:visited {
    -    text-decoration: underline;
    +    ¶
       }
    

    Here's the same: it leaves an empty space and an empty declaration.

  3. +++ b/css/src/components/messages.css
    @@ -96,7 +96,6 @@
    -  text-decoration: underline;
    

    Why is this removing the underline from messages? We should keep it.

  4. +++ b/css/src/components/pager.css
    @@ -144,7 +144,7 @@
    -    text-decoration: underline;
    +   ¶
    

    Another empty declaration after changes.

  5. +++ b/css/src/components/vertical-tabs.css
    @@ -67,7 +67,7 @@
     .vertical-tabs__menu-item a:focus .vertical-tabs__menu-item-title {
    -  text-decoration: underline;
    +  ¶
    

    Empty declaration after removing the code.

Also, probably reviewing @andrewmacpherson's suggestion from comment #11 to config your editor might help you avoiding empty spaces added to the patch. :)

andrewmacpherson’s picture

#13.3:

Why is this removing the underline from messages? We should keep it.

Because links will be underlined by default, aftee elements.css has been fixed. We don't need to add the underline in messages.css

charlieweb82’s picture

Status: Needs work » Needs review
FileSize
4.9 KB

base on the comment #4 remove the a, .link rule the other section have underline everywhere so I added base on the component the text-decoration: none to remove underline on some elements. I fix the spacing and empty rules.

lauriii’s picture

+++ b/css/src/components/tables.css
@@ -146,6 +147,9 @@ td {
+td a {
+  text-decoration: none;
+}

Is there a particular reason we want to remove the underline from links in tables?

charlieweb82’s picture

Where the update of the patch base on comment #16

fhaeberle’s picture

Correcting custom commands fail: formatting issue.
@charlieweb82 Before creating the patch, please run `yarn lint:css` (in terms of css changes) to check for errors. Thanks for your help! :)

lauriii’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
15.58 KB

We should remove the underline from links in pager:

charlieweb82’s picture

Status: Needs work » Needs review
FileSize
8.73 KB

Update patch base on comment #19 from @lauriii

charlieweb82’s picture

lauriii’s picture

Issue tags: +Needs reroll
charlieweb82’s picture

update patch with fix.

fhaeberle’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll +Needs followup

Out of the meeting yesterday:

So we will use underline for all links for now. We will open a follow-up to improve the design of tables to make it less busy. – @lauriii

Patch applies and works for me. Underline in pager was removed.

saschaeggi’s picture

FileSize
101.62 KB

Also making sure buttons don't use the underline as well. We should also use a darker blue color for :hover & :active. The colors are specified:
Colors definied for Claro

also you can have a look here: https://www.figma.com/file/OqWgzAluHtsOd5uwm1lubFeH/Drupal-Design-system...

fhaeberle’s picture

@saschaeggi Changing the (underline) colors sounds like a follow-up (EDIT: I created one.) and should be also applied globally.

saschaeggi’s picture

@fhaeberle should be the default for all links. Thanks. I linked it.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
10.69 KB

For more consistency, we should extend this to button.link elements as well:

Gayathri J’s picture

#23
I applied this patch works for me underline in pager was removed.

andrewmacpherson’s picture

#28 - yes, good catch.

kostyashupenko’s picture

Status: Needs work » Needs review
FileSize
4.69 KB
235 bytes
lauriii’s picture

  • lauriii committed 8fb8f5d on 8.x-1.x
    Issue #3079134 by charlieweb82, fhaeberle, kostyashupenko,...
lauriii’s picture

Status: Needs review » Fixed

This looks great! 🚀 Thanks everyone for your help!

Gayathri J’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.