Pasted text messing up your website's formatting? Clean it
Short answer: When text copied from a document, an email or another website is pasted into your CMS, it often brings hidden HTML with it: fixed fonts and colours, inline styles, empty spans, odd spacing and sometimes invisible characters. The page then looks inconsistent, breaks on phones, ignores your theme and is harder to edit. Paste as plain text (in most browsers, Ctrl+Shift+V or Cmd+Shift+Option+V), then format with the editor's own headings and lists. For content already published, use the editor's clear-formatting option or the HTML view to remove the junk, and consider configuring your editor to strip styles on paste.
Why pasting brings junk
When you copy, the source application usually places the content on the clipboard in more than one format, typically a rich HTML version and a plain-text version. MDN's documentation of the DataTransfer.getData() method describes retrieving data by format, with examples like text/plain, and its documentation of the paste event explains that code handling a paste can read the clipboard contents through the event's clipboardData and override the default behaviour, for example to insert a transformed version.
Rich-text editors in website CMSs generally prefer the HTML version, because it keeps bold, links and lists. But that HTML often also carries the source's visual styling: font families, sizes, colours, line heights, margins and class names that mean nothing on your site.
What the junk looks like
Visible symptoms:
- Some paragraphs in a different font or size from the rest of the site.
- Text that's black on your dark theme, or a white background behind pasted paragraphs.
- Extra blank lines or strange gaps.
- Headings that look like headings but are really bold paragraphs, so they don't appear in your table of contents or help screen readers.
- Lists made of typed hyphens or numbers instead of real list markup.
In the HTML view you'll see things like <span style="font-family: ...; font-size: 11pt; color: #000000">, empty <span> tags, sequences and unfamiliar class names.
Why it matters
- Consistency: pasted styles override your theme, so pages look patchy.
- Mobile layout: fixed widths and font sizes can break small screens.
- Accessibility: fake headings and lists don't convey structure to assistive technology, and fixed colours may fail contrast in dark mode.
- Maintenance: a future theme change won't update pasted inline styles.
- Page weight: heavy markup adds bytes to every page.
Step 1: Paste the right way
- Paste as plain text, using the browser's paste-without-formatting shortcut or the editor's "paste as text" option where available.
- Then format in the editor: apply headings, lists, bold and links with the CMS's tools.
- For links, re-add them after pasting plain text, or check pasted links point where you expect.
Writing directly in the CMS, or in a plain-text editor, avoids most of the problem.
Step 2: Clean what's already published
- Find affected pages. Look for pages that look inconsistent, or search your database or exported content for
style="andfont-familyin post content. - Use "clear formatting". Most editors have a button that removes inline styles from selected text. Select a paragraph, clear it, and reapply proper formatting.
- Use the HTML or code view for stubborn cases: delete
spantags with style attributes, remove empty tags, and replace fake headings with real heading elements. - Re-paste as plain text if a section is badly affected; it's often quicker than cleaning.
For large sites, a developer can write a careful script to strip inline styles from post content in bulk. Back up first and test on a copy.
Step 3: Stop it at the editor
Developers can configure many editors to clean pasted content automatically:
- Strip inline styles and classes on paste, keeping only allowed elements such as headings, paragraphs, lists, links, bold and italic.
- Limit the available formatting in the editor so editors can't add arbitrary fonts and colours.
- Use the
pasteevent in custom editors to transform pasted HTML, as MDN describes.
Content-security and sanitising libraries can also enforce an allowed list of HTML elements when content is saved.
Step 4: Give editors a simple guide
A short checklist for whoever edits the site:
- Write in the CMS or a plain-text editor where possible.
- Paste as plain text.
- Use the heading and list buttons, not bold and typed hyphens.
- Preview on a phone before publishing.
Emails and newsletters too
The same problem appears when content pasted into your website is later reused in an email newsletter, or when text from an email is pasted into a product description. Email clients are even less forgiving of stray styles than browsers, so a pasted font or colour can look very different in a customer's inbox. Keep product descriptions, FAQs and announcements clean at the source, and they'll display consistently wherever they're reused, including feeds, marketplaces and apps that pull content from your site.
Check after theme changes
A redesign is a good moment to find pasted styles, because they're the parts of the site that refuse to change. After switching theme, browse key pages and note anything that still looks like the old design; it's usually inline formatting.
An illustrative example
A hypothetical Winnipeg community theatre's volunteers wrote show descriptions in a word processor and pasted them into the website. Pages had three different fonts, black text on the theme's dark sections and headings that were just large bold text. The web volunteer cleaned the top 20 pages using clear formatting and the HTML view, configured the editor to strip styles on paste, and gave volunteers a one-page guide. New pages now match the theme automatically.
FAQ
Will pasting as plain text remove my links?
Yes, usually. Re-add links in the editor.
Is this only a WordPress problem?
No. Most CMSs and website builders with rich-text editors behave similarly.
Can invisible characters cause problems?
Yes. Non-breaking spaces and zero-width characters can affect line wrapping and search.
Does it affect SEO?
Fake headings lose structure, and heavy markup adds weight. Clean content is easier for everyone.
If your website pages look inconsistent after content was pasted in, send us a couple of example pages.