Add default class to anchor link

Created on 17 September 2021, over 3 years ago
Updated 24 September 2024, 7 months ago

Is there a way to add a class to an anchor link? I'd like to automatically add the same class to all anchor links so that some specific CSS can be applied to each. Can I write a hook for this?

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mxwright

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Yeah I also need this feature

  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

    If I remember correctly, the CKEditor 4 version of anchor link adds both an id and name attribute to all anchors. Maybe you could select <a> elements that have both attributes? For example:

    a[id][name] {
      /* your styles here */
    }

    Depending on other styles in play, you might have to use !important to get them to work.

    This assumes your text format/filter is allowing both attributes through to the rendered content

Production build 0.71.5 2024