Problem/Motivation
Non-hyperlink anchors (a elements) have hyperlink styling for example- In the body, add something like -
<a name="foo">Foo</a>: Foo
<a href="bar">Bar</a>: Bar
You will see that both have the same hyperlink styling even when an anchor has no href attribute.
Steps to reproduce
- Create a blank site, with Olivero default theme
- Create a node with a format allowing the
<a>element - In the body, add something like
<a name="foo">Foo</a>:Foo - In the body, add something like
<a href="bar">Bar</a>:Bar - Observe (cf. screenshot) they both carry Olivero's hyperlink "underline" styling.
- The only hint is for those who can use one is the cursor styling not switching to the hand shape

This is an accessibility issue: users will believe the a.name is a link and be frustrated to find it is not clickable until they notice the cursor shape.
The same problem exists in Bartik and in the drupal.org theme (see the list just above), but not in Claro.
Proposed resolution
Do not style a.name at all unless it is also a a.href. This is an attribute meant for browsers, not for user consumption.
Remaining tasks
Identify the source of this behaviour, and fix it.
User interface changes
Links which are not hyperlinks will no longer look like hyperlinks.
- Before:

- After:

API changes
None.
Data model changes
None.
Release notes snippet
TBD.
| Comment | File | Size | Author |
|---|---|---|---|
| #59 | AfterMR.png | 15.32 KB | kanchan bhogade |
| #59 | BeforeMR.png | 15.11 KB | kanchan bhogade |
| #58 | After_patch_3374889.png | 307.13 KB | manibharathi ezhimalai ravi |
| #58 | Before_patch_3374889.png | 313.85 KB | manibharathi ezhimalai ravi |
| #54 | a-tag-after.png | 118.94 KB | meeni_dhobale |
Issue fork drupal-3374889
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3374889-non-hyperlink-anchors-a
changes, plain diff MR !5328
- 11.x
changes, plain diff MR !5493
Comments
Comment #2
fgmComment #3
fgmComment #4
gauravvvv commentedI have attached a patch and added after patch screenshot for same. please review
Comment #5
fgmComment #6
fgmComment #7
kushagra.goyal commentedVerified the latest patch and after applying #4 patch it is working fine. For reference attaching before and after screenshots.
Comment #8
indrapatil commentedI tested this patch and it's working as expected I attached the screenshot for this after testing.
RTBC + 1.
Thank you
Comment #9
shiv_sharma commented@fgm I have one concern that why it is required to add
<a name="foo">Foo</a>: Fooif we are not using href in anchor tag then what is the use of
<a name="foo">Foo</a>: FooComment #10
fgm@shiv_sharma : it makes that anchor addressable with a URL fragment, like
https://somesite/somepage#foo, which is useful for in-page navigation with long form content.Comment #11
smustgrave commented@fgm do you have any accessibility links that this is an issue?
Comment #12
fgm@smustgrave: you mean some reference documenting the fact that making a non-clickable item look just like a clickable one is not a good idea ? I'm afraid not, so I asked ChatGPT and it gives a well-articulated explanation similar to what I would have written, just better said:
Comment #13
smustgrave commentedIn that case I don't see any issue. Will also ask one of the Olivero maintainers to chim in though.
Comment #15
fgmComment #16
fgmTest failure was a CI fluke: tests pass again, resetting to RTBC.
Comment #17
quietone commentedI'm triaging RTBC issues.
After reading the IS and comments I don't see anything left to do. Leaving at RTBC.
Comment #18
lauriiiI don't think we want the blue color or even hover styles for the anchor links because they are not interactable. Styles for these are in base.pcss.css.
Comment #19
smustgrave commented#18 makes sense.
Comment #20
laurielim commentedDrupal Helsinki Sprints 2023/11 - working on this based on #18
Comment #22
laurielim commentedUpdated base.pcss.css so styling is applied only to
<a>tags that have href attribute. Similar change had to also be made to text-content.pcss.css.Comment #23
fgmIn my not-expert experience, there is a tendency to have non-link A elements visible on hover, sometime with a dashed underline. The goal, again, is to provide information to the user that there is an addressable resource at that point.
On d.o. itself, you can see it on this issue summary: when hovering over the third and fourth items in the list, you will notice that a blue color is applied as well as an underline. No idea whether this is just the same issue or an actual decision.
Comment #24
simohell commentedW3C's "HTML and XHTML Techniques for WCAG 2.0" has an example code for using a-tag without an href attribute and without text content (so obviously invisible to sighted users) - but it does not discuss presentation in case there would be some text. An h-tag linked from an a with href in that document is not styled differently from other headings though. This feels like a contradiction to what is said in #23.
https://www.w3.org/TR/WCAG20-TECHS/html.html#H86-ex2
There is a case of links without hrefs though. It is possible to have an
<a role="link">text</a>or more commonly an image or a span. Semantic HTML is however considered best practise.I could bring this up during tomorrows accessibility office hours if somebody else doesn't want to do it.
Comment #25
simohell commentedComment #26
shaalWhen styling anchor elements, it might be better to use the
:linkpseudo-class instead of styling theaelement itself. The:linkselector specifically targets anchors containing an href attribute, while avoiding styling anchor elements with just a name.Using
:linkimproves specificity and avoids inadvertently styling elements that aren't links.Reference:
https://developer.mozilla.org/en-US/docs/Web/CSS/:link
Comment #29
nitin shrivastava commentedThank you @shaal for your guidance on the best approach to differentiated styling for links and non-links. To style unvisited links specifically, a:link is more suitable as it targets only those links.
Updated in above MR. Please review and merge.
Comment #30
smustgrave commentedWhy open a new MR for a small change to the existing MR5328?
believe 5493 should be closed and consolidated into 5328 since 5328 still points to the correct branch too.
Also if we are changing solutions the issue summary will have to reflect that.
Comment #31
nitin shrivastava commented@smustgrave Apologies for the noise. I'll address this promptly by updating 5328 with the necessary changes and also revising the issue summary.
Comment #32
nitin shrivastava commented@smustgrave, could you possibly take a look? I'm new to MRs, so if I've made any mistakes, I'd really appreciate your guidance
Comment #34
shweta__sharma commentedRebased MR
Comment #35
shweta__sharma commentedUpdated issue summary.
Comment #36
shweta__sharma commentedComment #37
smustgrave commentedReading the issue summary, as a UI change before/after screenshots in the issue summary should be included for quicker reviews.
Comment #38
fgmComment #39
fgmAdded images in IS.
Comment #40
smustgrave commentedComment #41
mgiffordThis makes sense to me. It's a simple change, but one that I think can avoid some confusion for users expecting a link.
Comment #42
smustgrave commentedThanks! @mgifford
Comment #43
larowlanPinged maintainers in slack for a +1
Comment #44
mherchelAccording to https://developer.mozilla.org/en-US/docs/Web/CSS/:link,
My worry on this patch is twofold:
1. The changes will break visited links. There's mention of this in #29, but we definitely want link styling to still apply to visited links.
2. The
:linkpseudo-class creates extra specificity that might break other styling. Let's use:where()to remove this specificity. Something along the lines ofa:where([href])as the selector.Thanks for all the work on this everybody. Sorry to set this back to NW.
Comment #46
ahsannazir commentedComment #47
yevko commentedReviewed the PR, made a small comment.
In UI everything works as expected.

In Claro though, a link without href has an accent color. Shall we handle the same change for Claro?

Comment #48
ahsannazir commentedThe issue is related to Olivero theme only. Maybe you can create a seperate issue for claro @YevKo
Comment #49
fgmComment #50
fgmNote that the issue is not entirely equivalent in Claro, so the fix might not be the exact same: it has the color change but not the text-decoration, unlike Olivero.
Comment #51
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #52
ahsannazir commentedComment #53
wroxbox commentedRelated to this: https://www.drupal.org/project/drupal/issues/3372666 from way too long.
Comment #54
meeni_dhobale commentedI reviewed and tested the current MR. The changes are looks fine to me. the changes are worked for Non-hyperlink anchors only. Adding before and after effects.
Before:
After:
I think this issue has to be in RTBC.
Comment #55
smustgrave commentedAppears to be 2 MRs both against 11.x one should be closed or hidden.
Comment #57
ahsannazir commentedComment #58
manibharathi ezhimalai ravi commentedHi,
I've reviewed the MR !5328 on Drupal 11.x.
Test Results:
Non link text is appearing without any link styles in the content.
Comment #59
kanchan bhogade commentedTested MR !5328 on the Drupal 11
The MR is applied Cleanly...
Test Result:
The No hyperlink text does not show the hyperlink style.
Attaching Screenshots for reference
RTBC+1
Comment #60
smustgrave commentedJust FYI for everyone uploading screenshots. Only the first set get credit. Re-uploading additional sets is just duplicative work.
Comment #61
smustgrave commentedThis one has bounced around a few months. Saving credit for those who have worked on the MR but not for the duplicate screenshots.
Left a comment on the MR.
Comment #63
quietone commentedThe Olivero theme was approved for removal in #3590816: [policy, no patch] Deprecate Olivero and move to contrib.
This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
The deprecation work is in #3595082: [meta] Tasks to deprecate the Olivero theme and the removal work in #3595085: [meta] Tasks to remove the Olivero theme.