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

a.name looking like a a.href

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: Before patch
  • After: After patch

API changes

None.

Data model changes

None.

Release notes snippet

TBD.

Issue fork drupal-3374889

Command icon 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:

Comments

fgm created an issue. See original summary.

fgm’s picture

Issue summary: View changes
fgm’s picture

Issue summary: View changes
gauravvvv’s picture

Status: Active » Needs review
StatusFileSize
new1.86 KB
new403.96 KB

I have attached a patch and added after patch screenshot for same. please review

fgm’s picture

Issue summary: View changes
fgm’s picture

Issue summary: View changes
kushagra.goyal’s picture

StatusFileSize
new61.96 KB
new42.31 KB

Verified the latest patch and after applying #4 patch it is working fine. For reference attaching before and after screenshots.

indrapatil’s picture

StatusFileSize
new9.87 KB

I tested this patch and it's working as expected I attached the screenshot for this after testing.
RTBC + 1.
Thank you

shiv_sharma’s picture

@fgm I have one concern that why it is required to add <a name="foo">Foo</a>: Foo

if we are not using href in anchor tag then what is the use of <a name="foo">Foo</a>: Foo

fgm’s picture

@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.

smustgrave’s picture

@fgm do you have any accessibility links that this is an issue?

fgm’s picture

@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:

As of my last update in September 2021, there were no specific WCAG guidelines or official documents that explicitly state that an HTML "a" element without an "href" should not be made to look the same as one with an "href" for accessibility purposes. However, there are some reasons and best practices related to accessibility that can help guide this decision.

Semantic Meaning: The HTML "a" element is used for creating hyperlinks. When you use an "a" element without an "href" attribute, it loses its semantic meaning as a hyperlink. Screen readers and other assistive technologies rely on semantic HTML to provide context to users. Making an "a" element without an "href" look like a hyperlink may be confusing to users who rely on assistive technologies.

User Expectations: Users expect the visual appearance of interactive elements to be consistent across the web. When they see an underlined or differently colored text, they anticipate it to be a clickable link. Inconsistent visual cues can lead to user confusion and frustration, especially for users with disabilities who may rely on specific visual patterns to navigate the web.

Keyboard Navigation: Users who navigate the web using a keyboard (e.g., using the "Tab" key to move through links) may encounter difficulty if an "a" element without an "href" is made to look like a hyperlink. They may find a visual link that they cannot activate using the keyboard, which can be a frustrating user experience.

SEO and Crawlers: Search engines and web crawlers may interpret an "a" element without an "href" as a broken or irrelevant link, potentially affecting SEO and indexing.

While there might not be specific WCAG guidelines that directly address this issue, the concept of providing clear and consistent user interfaces for all users, including those with disabilities, is a core principle of web accessibility. The Web Content Accessibility Guidelines (WCAG) emphasize creating a perceivable and understandable user experience, which aligns with the reasons mentioned above.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Bug Smash Initiative

In that case I don't see any issue. Will also ask one of the Olivero maintainers to chim in though.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: 3374889-4.patch, failed testing. View results

fgm’s picture

Issue summary: View changes
fgm’s picture

Status: Needs work » Reviewed & tested by the community

Test failure was a CI fluke: tests pass again, resetting to RTBC.

quietone’s picture

I'm triaging RTBC issues.

After reading the IS and comments I don't see anything left to do. Leaving at RTBC.

lauriii’s picture

Status: Reviewed & tested by the community » Needs review

I 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.

smustgrave’s picture

Status: Needs review » Needs work

#18 makes sense.

laurielim’s picture

Assigned: Unassigned » laurielim
Status: Needs work » Active

Drupal Helsinki Sprints 2023/11 - working on this based on #18

laurielim’s picture

Assigned: laurielim » Unassigned
Status: Active » Needs review

Updated 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.

fgm’s picture

In 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.

simohell’s picture

W3C'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.

simohell’s picture

shaal’s picture

When styling anchor elements, it might be better to use the :link pseudo-class instead of styling the a element itself. The :link selector specifically targets anchors containing an href attribute, while avoiding styling anchor elements with just a name.

Using :link improves specificity and avoids inadvertently styling elements that aren't links.

Reference:
https://developer.mozilla.org/en-US/docs/Web/CSS/:link

Nitin shrivastava made their first commit to this issue’s fork.

nitin shrivastava’s picture

Thank 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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Why 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.

nitin shrivastava’s picture

@smustgrave Apologies for the noise. I'll address this promptly by updating 5328 with the necessary changes and also revising the issue summary.

nitin shrivastava’s picture

Issue summary: View changes

@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

shweta__sharma made their first commit to this issue’s fork.

shweta__sharma’s picture

Rebased MR

shweta__sharma’s picture

Issue summary: View changes

Updated issue summary.

shweta__sharma’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs screenshots

Reading the issue summary, as a UI change before/after screenshots in the issue summary should be included for quicker reviews.

fgm’s picture

Issue summary: View changes
fgm’s picture

Status: Needs work » Needs review

Added images in IS.

smustgrave’s picture

Issue tags: -Needs screenshots
mgifford’s picture

This makes sense to me. It's a simple change, but one that I think can avoid some confusion for users expecting a link.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! @mgifford

larowlan’s picture

Pinged maintainers in slack for a +1

mherchel’s picture

Status: Reviewed & tested by the community » Needs work

According to https://developer.mozilla.org/en-US/docs/Web/CSS/:link,

The :link CSS pseudo-class represents an element that has not yet been visited. It matches every unvisited or element that has an href attribute.

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 :link pseudo-class creates extra specificity that might break other styling. Let's use :where() to remove this specificity. Something along the lines of a:where([href]) as the selector.

Thanks for all the work on this everybody. Sorry to set this back to NW.

ahsannazir made their first commit to this issue’s fork.

ahsannazir’s picture

Status: Needs work » Needs review
yevko’s picture

Reviewed the PR, made a small comment.

In UI everything works as expected.
Oliviero UI

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

ahsannazir’s picture

The issue is related to Olivero theme only. Maybe you can create a seperate issue for claro @YevKo

fgm’s picture

Issue summary: View changes
fgm’s picture

Note 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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.91 KB

The 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.

ahsannazir’s picture

Status: Needs work » Needs review
wroxbox’s picture

Related to this: https://www.drupal.org/project/drupal/issues/3372666 from way too long.

meeni_dhobale’s picture

StatusFileSize
new131.62 KB
new118.94 KB

I 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.

smustgrave’s picture

Status: Needs review » Needs work

Appears to be 2 MRs both against 11.x one should be closed or hidden.

ahsannazir changed the visibility of the branch 11.x to hidden.

ahsannazir’s picture

Status: Needs work » Needs review
manibharathi ezhimalai ravi’s picture

StatusFileSize
new313.85 KB
new307.13 KB

Hi,
I've reviewed the MR !5328 on Drupal 11.x.

Test Results:
Non link text is appearing without any link styles in the content.

kanchan bhogade’s picture

StatusFileSize
new15.11 KB
new15.32 KB

Tested 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

smustgrave’s picture

Just FYI for everyone uploading screenshots. Only the first set get credit. Re-uploading additional sets is just duplicative work.

smustgrave’s picture

Status: Needs review » Needs work

This 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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Needs work » Postponed

The 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.