Write the best markdown you've ever created with these 5 snippets 🔥
Tags: beginners, programming, tutorial, writing
Published: 2023-10-18 11:55:05

## Table of Contents
- [Interactive Anchor](#anchor)
- [Browser Compatibility](#compat)
- [Featured Image](#highlight)
- [Native Accordion](#accordion)
- [Centered Callout](#callout)
- [Free Icons](#icons)

<br />

------

</br>

## Interactive Anchor <a id="ancora" href="#ancora">&#128279;</a>

Some HTML elements are supported in Markdown, and one of them is the anchor `<a>`. In addition to linking to content on other pages, it's also possible to reference sections within the same page. When we create headings in Markdown, they automatically create anchors, but the advantage of using a anchor tag is that clicking on the icon allows you to place the fragment in the URL directly by the heading.

&nbsp;

🧐 **Example**

## :active <a id="active" href="#active">&#128279;</a>

&nbsp;

{% spoiler 📝 **Source code** %}

```html
## :active <a id="active" href="#active">&#128279;</a>
```

{% endspoiler %}

<br />

------

</br>

## Browser Compatibility Table <a id="compat" href="#compat">&#128279;</a>

I borrowed this component from the web.dev CSS course, and it's a great way to display browser compatibility in your documentation. Unfortunately, DevTo doesn't recognize this syntax, but GitHub and VSCode do!

&nbsp;

🧐 **Example (Doesn't work here on DevTo)**

![Browser Compatibility Table](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6s2w5kso3km0evcjxb8l.png)

&nbsp;

{% spoiler 📝 **Source code** %}

```html
<span>
  Compatibilidade com navegadores
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/au2ph8juz4l6gu8m6v99.png" width="18" height="18" alt="chrome" /> 1
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oc95bmrx1ic1yv2ufxnp.png" width="18" height="18" alt="edge" /> 12
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnv0yb558uyvttyxnsz7.png" width="18" height="18" alt="firefox"/> 1
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ae4m3sedx2hcpf5nkr0a.png" width="18" height="18" alt="safari"/> 1
</span>
```

{% endspoiler %}

&nbsp;


🧐 **Example (This one works!)**

| <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/au2ph8juz4l6gu8m6v99.png" width="18" height="18" alt="chrome" /> | <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oc95bmrx1ic1yv2ufxnp.png" width="18" height="18" alt="edge" /> | <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnv0yb558uyvttyxnsz7.png" width="18" height="18" alt="firefox"/> | <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ae4m3sedx2hcpf5nkr0a.png" width="18" height="18" alt="safari"/> |
| --- | --- | --- | --- |
| 1 | 12 | 3 | 1 |

&nbsp;

{% spoiler 📝 **Source code** %}

```html
| <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/au2ph8juz4l6gu8m6v99.png" width="18" height="18" alt="chrome" /> | <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oc95bmrx1ic1yv2ufxnp.png" width="18" height="18" alt="edge" /> | <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnv0yb558uyvttyxnsz7.png" width="18" height="18" alt="firefox"/> | <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ae4m3sedx2hcpf5nkr0a.png" width="18" height="18" alt="safari"/> |
| --- | --- | --- | --- |
| 1 | 12 | 3 | 1 |
```

{% endspoiler %}

<br />

------

</br>

## Featured Image 🔗 <a id="highlight" href="#highlight">&#128279;</a>

Using the `<figure>` and `<figcaption>` elements yields a result quite similar to images in Medium posts. The `<figcaption>` describes the image, and using the `<img>` tag itself allows us to change the height and width properties, providing greater control over the artistic direction of the markdown.

&nbsp;

🧐 **Example**

<figure> 
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zmtdzk3zfsdvafrdc7wn.png" alt="Cartoon icon of a person" />

  <figcaption>C# e Código, from Twitter</figcaption>
</figure>

&nbsp;

{% spoiler 📝 **Source code** %}

```html
<figure> 
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zmtdzk3zfsdvafrdc7wn.png" alt="Cartoon icon of a person" />

  <figcaption>C# e Código, from Twitter</figcaption>
</figure>
```

{% endspoiler %}

<br />

------

</br>

## Native Accordion <a id="accordion" href="#accordion">&#128279;</a>

Perfect for when you want to hide long sections like trivia, source code, etc.

&nbsp;

🧐 **Example**

{% spoiler 📝 **Spoiler?** %}

> What u looking at?

{% endspoiler %}

&nbsp;

{% spoiler 📝 **Source code** %}

```html
<details>
  <summary>Spoiler?</summary>
  
  > What u looking at? 

</details>
```

&nbsp;

Specifically in the case of DevTo, we use:

```md
Copy code
{% details summary %} content {% enddetails %}
{% spoiler summary %} content {% endspoiler %}
{% collapsible summary %} content {% endcollapsible %}
```

{% endspoiler %}

<br />

------

</br>

## Centered Callout <a id="callout" href="#callout">&#128279;</a>

Unfortunately, DevTo is allergic to `<div>`, but it works like a charm on GitHub and most Markdown readers. Perfect for that section that needs attention or directs to someplace.

&nbsp;

🧐 **Example**

![Centered phrase with a link indicating the next page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh2plzaigh9io8mz2p5l.png)


&nbsp;

{% spoiler 📝 **Source code** %}

```html
<div align="center">
  **Next Page &rarr; [Pseudo-classes](./2-pseudo-classes.md)**
</div>
```

{% endspoiler %}


<br />

------

</br>

## Free Icons <a id="icons" href="#icons">&#128279;</a>

[There's a enormous list of HTML code icons](https://www.toptal.com/designers/htmlarrows/symbols/)  (I've used 2 in this article alone), just copy and paste!

We have the most basic ones like arrows &rarr; (`&rarr;`) and &larr; (`&larr;`), and others more specific like &#9773; (`&#9773;`). Since emojis take up more vertical space, causing a line break ✋, these icons are a good solution when you just need to add a touch to your documentation.

&nbsp;

🧐 **Example**

> &#10077; Error is what is wrong  &#10078;
> &emsp; &emsp; - _Charles Darwin_

&nbsp;

{% spoiler 📝 **Source code** %}

```html
> &#10077; Error is what is wrong  &#10078;
> &emsp; &emsp; - _Charles Darwin_
```

{% endspoiler %}

&nbsp;
You can also use special spacing characters to create custom spaces, almost like Tailwind for Markdown. In the element below, the pipe | signals the beginning and end of the spacing.

| &thinsp; | - `&thinsp;`
| &nbsp; | - `&nbsp;`
| &ensp; | - `&ensp;`
| &emsp; | - `&emsp;`

<br />

------

</br>

So, did you learn something new? Anything you didn't know? Share your Markdown hacks with the community in the comments!