How to add space (" ") after an element using :after selector in CSS ? Last Updated : 03 Aug, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The :after selector in CSS is used to add the same content multiple times after the content of other elements. It inserts something after the content of each selected element. Syntax: :after { // CSS Property}Example 1: This example uses :after selector to add space after an element. html <!-- HTML code to add space after the selected element --> <!DOCTYPE html> <html> <head> <title> Add space after selected element </title> <!-- Style to add space after selected element --> <style> p:after { content:"\00a0 World-with space" } p.GFG:after { content:"World-without space" } </style> </head> <body> <p>Hello</p> <p class="GFG">Hi</p> </body> </html> Output: Example 2: This example uses :after selector to add space after an element. html <!-- HTML code to add space after the selected element --> <!DOCTYPE html> <html> <head> <title> Add space after selected element </title> <!-- Style to add space after the selected elements --> <style> h2 { text-decoration: underline; } h2.space:after { content: " "; white-space: pre; } </style> </head> <body> <h2>I don't have a space:</h2> <h2 class="space">I have a space:</h2> </body> </html> Output: Comment More infoAdvertise with us Next Article How to insert line break before an element using CSS? S sheyakhare1999 Follow Improve Article Tags : Web Technologies CSS CSS-Misc Similar Reads How to insert line break before an element using CSS? The white-space property is used to insert the line break before an element. This property controls the text wrapping and white-spacing. Line break between the lines: The line break can be added between the line of text. The white-space: preline; is used to insert line break before an element. Examp 2 min read How to set padding around an element using CSS ? In this article, we will learn How to set the padding around an element using CSS. Approach: The padding is the space between the content of the element and its boundaries. We can set the padding around an element using the padding property of the CSS. It takes four values top_padding, right_padding 1 min read How to insert a DOM element after all paragraphs using jQuery ? In this article, we will insert a DOM element after all paragraph elements using jQuery. To insert a DOM element we use after() and createTextNode() methods. The createTextNode() method is used to create a TextNode which contains an element node and a text node. It is used to provide text to an elem 1 min read How to set padding inside an element using CSS? In this article, we are going to see how to set padding inside an element using CSS. Padding is considered as the space between content and its border. The padding creates space inside defined borders. The difference between padding and margin is that margin creates space outside borders and padding 1 min read How to use ::before and ::after elements in Tailwind CSS ? In Tailwind CSS, we can use the ' :: before ' and ' :: after ' pseudo-elements by adding utility classes directly in your HTML. Simply apply the "before:" or "after:" prefix followed by the desired utility classes to style elements before or after their content. Using Utility ClassesTailwind CSS off 1 min read How to use :before or :after pseudo-element to an input field in CSS ? Input tag (<input>) in HTML is used to take input from the user like text input, button input, file input, etc. In CSS, pseudo-elements are basically specific keywords that are added to a selector to style a specific part of the selected element. For example: ::before, ::after etc. The pseudo- 3 min read Like