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

244
Views
How do I "unitalicize" a single word in an HTML span container that is already styled for italics?

Inputing text via java into an HTML span container, like this:

<p><span id="myID" style="text-align: justify; display: block; font-style: italic;"></span>...

In the text I am inputing, in one case, a single word is not italic. How do I unitalicize the word?

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

0

document.getElementById("myID").style.fontStyle = "normal";

about 4 years ago · Juan Pablo Isaza Report

0

Modern front-end methods suggest you use CSS classes instead of inline styles in the markup.

Set the span to one main class identified by the id, and an italic class, and then use the JS to toggle the italic class off with classList.

// Cache the element, and set the innerText
const span  = document.querySelector('#myID');
span.innerText = 'This is my text.';

// For an example wait one second to
// toggle the italic class
setTimeout(() => {
  span.classList.toggle('italic');
}, 1000);
#myID { text-align: justify; }
.italic { font-style: italic; }
<p><span id="myID" class="italic"></span></p>

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!