Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
How to insert a complex div inside a string in ReactJs?

I am working on a ReactJs and I have to style a div inside a string

Here is the string I am talking about

const instruction1 = <div>XXXXXX: xxxx <div>{state.numbers[0]}</div>, xxxxxx xxxxxxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxxxxxxx xxxxxxxxxxx xxxxxx xxxxxxxxxx</div>

But the outcome is something like this enter image description here

But I need the outcome to be like this

enter image description here

The problem is that I have to use a div because there will be multiple elements inside that div.

Why is using the div tag mess up the design?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

div is a block element, it means in the HTML it will look like in a new row. Try to use span instead. It will not break the line.

Update: not sure why you need div at all. It seems you could put your items directly to the root div:

<div>XXXXXX: xxxx {state.numbers[0]}, {state.numbers[1]}, xxxxxx xxxxxxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxxxxxxx xxxxxxxxxxx xxxxxx xxxxxxxxxx</div>
about 4 years ago · Juan Pablo Isaza Report

0

In order to fix this, I wrapped the div in a span and gave display inline-block to that span

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!