Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set an empty paragraph element to the minimum height of the font-size (text)

How to set an empty paragraph element <p> to the height of the font size?

If a paragraph element is empty it has no height. How to set the minimum height to the text height (font-size)?

I know you can add &nbsp; to the element, but I want to set it purely by CSS

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use a whitespace in a pseudo-element. This should work:

p::after {
  content: '\00a0 '
}

Live demo here: https://jsfiddle.net/o96swntm/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading