Alan Alan - 7 months ago 7
HTML Question

Is there a way I can make a CSS selector put a "-" before a heading?

I have this CSS selector:

h3 {
font-size: 1rem;
}


Is there some way that I could make it change a heading:

Example


to

- Example

Answer

You can use the pseudo element :before to add content before it as such:

h3 {
  font-size: 1rem;
}

h3:before {
  content: '- ';
}
<h3>Example</h3>