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

199
Views
Placeholder text in <span> element is not working correctly specifically in Firefox

I am trying to create a placeholder in span element, and when user focus on the text the placeholder disappear and user are able to type something on it.

If you run the code below in other browser such as Chrome and Edge, the placeholder disappear correctly when you focus on the text, however on Firefox, you can't seems to focus or edit the text. I would like to know what's the difference between Firefox browser and others, and would also prefer if this can be resolve via CSS instead of Javascript.

HTML:

<body contenteditable="true">
<span style="font-size: 16pt; font-family: 'Verdana'; font-weight: bold;" data-runningid="1.1" data-placeholder="Enter new paragraph here..." class="newParagraphPlaceholder" data-mce-style="font-size: 16pt; font-family: 'Verdana'; font-weight: bold;">
</span>
</body>

CSS:

.newParagraphPlaceholder {
    display: inline-block;
}

.newParagraphPlaceholder:empty::before {
    content: attr(data-placeholder);
    color: grey;
}

Kindly refer to the demo here: https://jsfiddle.net/6L8gyfk7/2/.

Take note that there's a body with attribute contenteditable='true' tag wrapping the span tag that I need to preserve.

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

0

Because in Mozilla the -moz-user-focus is set to none by default, you can check this by going to console --> computed

You can fix this by

-moz-user-focus: select-after;
about 4 years ago · Juan Pablo Isaza Report

0

Something I don't get from your code though is why you're using so much styling within your ? You get the same result if you do

  <span class="newParagraphPlaceholder"data-runningid="1.1" data-placeholder="Enter new paragraph here..."></span>

.newParagraphPlaceholder {
    display: inline-block;
    font-size: 16pt;
    font-weight: bold;
}

Might be just me though, but with a long batch of code you're into a big struggle to adjust certain areas because it isn't properly written down in CSS.

about 4 years ago · Juan Pablo Isaza Report

0

I removed contenteditable from body to span and it woked and if you want to check browser support for css Property you can check here Codepen Link

.newParagraphPlaceholder {
    display: inline-block; 
  outline: none
}

.newParagraphPlaceholder:empty::before {
    content: attr(data-placeholder);
    color: grey; 

}
<!-- html is the same -->
<body >
  <span contenteditable="true"  style="font-size: 16pt; font-family: 'Verdana'; font-weight: bold;" data-runningid="1.1" data-placeholder="Enter new paragraph here..." class="newParagraphPlaceholder" data-mce-style="font-size: 16pt; font-family: 'Verdana'; font-weight: bold; color: #000; "></span>
</body>

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!