Adding classes to links in post body for styling

The way to do that is to use something like

For example

[wrap=link-button][Link Text](http://meta.discourse.org)[/wrap]

renders as

and the markup is

<div class="d-wrap" data-wrap="link-button">
  <p>
    <a href="http://meta.discourse.org">Link Text</a>
  </p>
</div>

and you can then style it in CSS using

[data-wrap="link-button"] {
  a {
    // styles for the link
  }
}

You can change [wrap=link-button] to any value you want like

[wrap=custom-button]
or
[wrap=home-link]
or
[wrap=foobar]

and then use that to target the link like the example above.

8 Likes