logo
search
SharePoint Document Issues

How to Fix SharePoint Online Inserting HTML Entities for Spaces

Khadija KhanKhadija Khan Oct 16, 2026 869 views

Question details

The user is experiencing issues where SharePoint Online automatically alters custom HTML code during editing, specifically modifying spaces and paragraph structures.

How to Fix SharePoint Online Inserting HTML Entities for Spaces
Product
SharePoint Online
Device & OS
not provided
Scenario
Editing HTML content or source code within SharePoint Online pages and web parts.
Observed behavior
SharePoint's content processor replaces standard spaces with the non-breaking-space entity ( ), generates unwanted line breaks in paragraphs, and automatically inserts empty span elements into the code.
Before you start

Before proceeding, ensure you have a backup of your original, clean HTML code saved locally in a plain text editor. Note that SharePoint's Rich Text Editor has built-in sanitization rules that automatically format and restructure code upon saving.

Solution 1Recommended

Report the HTML Modification Behavior to Microsoft Support

Since this involves the underlying behavior of the SharePoint content processor and HTML editor, reporting it with accurate replication steps is the best path toward a long-term resolution.

SharePoint Online utilizes a strict content-processing engine designed to sanitize code and prevent layout breaks. When it encounters raw HTML, it often forces its own formatting rules, which cannot easily be disabled by standard end-users.

1
Gather reproduction details

Document the specific SharePoint page type, the web part being used, your browser version, and save a sanitized snippet of the affected HTML code.

2
Contact your SharePoint administrator

Reach out to your organization's IT department or SharePoint admin to check if tenant-level custom scripting settings are affecting the editor's behavior.

3
Submit a support ticket

Sign in to the Microsoft Support forum or have your admin log into the Microsoft 365 Admin Center. Select 'Ask a question' or create a 'New service request' to report the automated code replacement issue.

Report the HTML Modification Behavior to Microsoft Support
Avoid Repeated Manual Edits: Do not continuously edit the affected HTML in the browser. SharePoint will repeatedly overwrite your corrections until the core platform behavior is investigated and addressed.
Free Microsoft Office alternative

Manage Your Document Source Files Offline with WPS Office

Dealing with complex text formatting and auto-correction issues in SharePoint can be frustrating. For your offline document creation and text drafting needs, WPS Office offers a free, lightweight, and highly compatible alternative to Microsoft Office, ensuring your formatting remains intact before you publish content online.

  1. 1. Download and Install: Get WPS Office from the official website and complete the quick, lightweight installation.
  2. 2. Draft Your Content: Open WPS Writer to draft your text or code snippets safely without aggressive auto-formatting applied by web browsers.
  3. 3. Save and Copy: Save your document locally in standard Microsoft formats or copy the clean text to paste directly into your web editor.
Draft text and prepare HTML snippets without unexpected web-editor formatting changes.Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx).Lightweight installation with a familiar, easy-to-use tabbed interface.Completely free to download and use for your daily documentation and drafting tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why does SharePoint replace regular spaces with the   entity?

SharePoint's Rich Text Editor automatically sanitizes and formats HTML to prevent web layout collapses. Multiple consecutive spaces or specific indentations are often converted into non-breaking space entities (  or  ) to ensure the spacing is preserved exactly as typed when viewed on the published web page.

Can I completely disable SharePoint's automatic HTML formatting?

There is no out-of-the-box toggle to completely disable HTML sanitization in standard SharePoint Modern Text web parts. Even if administrators enable custom scripts at the tenant level, standard text web parts will still process and clean up raw HTML upon saving.

How can I insert custom HTML code without SharePoint altering it?

To add custom HTML, CSS, or JavaScript without it being heavily altered by the standard text editor, use the Embed web part or the Markdown web part. For complex elements, developers should consider utilizing the SharePoint Framework (SPFx) for custom web part development.