Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:51:28+00:00 2026-06-04T14:51:28+00:00

Why do newlines appear as spaces or disappear on Enter/Return key in Opera for

  • 0

Why do newlines appear as spaces or disappear on Enter/Return key in Opera for contentEditable documents?

Try out this demo:

<!DOCTYPE html>
<html>
<head>
<title>contentEditable demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body contenteditable="true" spellcheck="true" dir="ltr">
<h1>Welcome to the contentEditable demo!</h1><p><span style="font-size: xx-large">
Try<span style="font-size: small">to type some text before the word "Try". You will see that random spaces are inserted before the word. Press Enter; you will see that the newline on the top disappears.</span></span></p></body>
</html>

Opera 11.50 Build 1074 on Windows Vista

Is this an Opera bug? I did not experience this bug with Windows Internet Explorer 8, Safari, Google Chrome, or Firefox 5.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:51:30+00:00Added an answer on June 4, 2026 at 2:51 pm

    I think that I may have discovered why from these links:

    [whatwg] Handling of collapsed whitespace in contenteditable:

    http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-June/032187.html

    • An nbsp at the end of a line makes the last word longer, so when you hit space, the last word on the line might jump to the next line. Then
      when you type a letter, the nbsp gets converted to a regular space and
      the word jumps back to the previous line.
      (I observed this in Opera.
      IE and Gecko seem to have some special-case to avoid this; WebKit
      avoids it with a more general hack that I’ll note later.)
    • An nbsp that winds up immediately before a word will cause the word to be indented if it happens to start a line. Gecko seems to be very
      careful to avoid this case, but all other engines do it sometimes.
    • A long run of spaces of which some are spaces and some are nbsp’s can result in nbsp’s at the beginning of a line. Thus if you type
      three spaces in between two words for whatever reason, in some cases
      the second word can be indented. This is probably not what users
      want.

    Bug 13011 – [editing] Encourage authors to use “white-space: pre-wrap” for contenteditable=”” and .designMode=true:

    https://www.w3.org/Bugs/Public/show_bug.cgi?id=13011

    Example of a potential problem without pre-wrap: if the user types
    “foo bar”, with two spaces in between, that will become either
    “foo  bar” or “foo  bar”. In the first case, “foo ”
    might wrap to the next line even though “foo” alone could fit on the
    current line. In the second case, if ” bar” starts a line, it
    will be visibly indented
    .

    Best practices for in-page editors:

    http://developers.whatwg.org/editing.html#best-practices-for-in-page-editors

    In the former case, “yellow⍽” might wrap to the next line (“⍽” being
    used here to represent a non-breaking space) even though “yellow”
    alone might fit at the end of the line; in the latter case, “⍽ball”,
    if wrapped to the start of the line, would have visible indentation
    from the non-breaking space
    .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It doesn't really have to add newlines, just something readable. Anything better than this?
I have the following style already: white-space: pre-wrap; This allows newlines to be treated
Is there a way to format the output of Select-String to include newlines between
I've seen this post: NSString: newline escape in plist but I'd like to know
I've a Java String with new lines(\n), say for example String value = This
I'm running backups against multiple databases hosted at Rackspace. This is working fine. The
this is my first time using any StackExchange website, so let's see how it
Certain fields in our mysql db appear to contain newline characters so that if
can't get the buttons in the OptionDialog to appear on a new line. They
This seems like such a simple requirement, that I feel like I am missing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.