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 make inline text with dangerouslySetInnerHTML

I have a li with a span that contains a text, and below I have some dangerouslySetInnerHTML. Problem, the html data goes below the first span. I want it to stay on the same line.

I also add that if the text is short, it works. If it is long, it goes on line below

Goal : "Informations : my informations"

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

Current : "Informations :
my informations"

I use TailwindCSS

I tried to use flex flex-wrap on container but still have same problem

How to solve this ?

My code :

<li className='flex flex-wrap'>
     <span className='font-semibold'>Eléments complémentaires :</span>
     <span className='break-words'
           dangerouslySetInnerHTML={{
              __html:"My test HTML without any tags",
           }}
      />
</li>

>Solution :

Everything looks correct, Perhaps you will be getting the spacing issue either on resize of your window (since you have flex-wrap:wrap or your container width is fixed and the text moves to new line.

Check if white-space: nowrap; can be a quick solution in this case.
Set it on break-words class.

.break-words {
   white-space: nowrap;
}
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