Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a space (" ") after an element using :after

Tags:

css

I want to add a blank space after some content, however the content: " "; doesn't seem to work.

This is my code:

h2:after {     content: " "; } 

... which doesn't work, however this does:

h2:after {     content: "-"; } 

What am I doing wrong?

like image 558
bradley.ayers Avatar asked Mar 29 '11 03:03

bradley.ayers


People also ask

How do you put a space after an element in CSS?

In most cases, you should be able to use the normal space character ( or \20 ) to add space before or after an element using the content property with ::before or ::after pseudo-elements.

How do you add a space between two elements?

To create extra spaces before, after, or in-between your text, use the   (non-breaking space) extended HTML character. For example, with the phrasing "extra space" using a double space, we have the following code in our HTML.

How can I add space after DIV in HTML?

In case you want additional space ( more than the default ) between div rows then you can add the following code before/after the start of the div row depending on where you want the additional space. This is easier but will add a fixed amount of gap.

How do you put spaces after words in HTML?

To insert blank spaces in text in HTML, type   for each space to add. For example, to create five blank spaces between two words, type the   entity five times between the words. You do not need to type any spaces between the entities.


1 Answers

Turns out it needs to be specified via escaped unicode. This question is related and contains the answer.

The solution:

h2:after {     content: "\00a0"; } 
like image 66
bradley.ayers Avatar answered Oct 04 '22 18:10

bradley.ayers