Re: PSA: HTML fragment mode interaction between Chromium, Clipboard & Notepad++

Maria Sophia <[email protected]> Tue, 10 Feb 2026 07:44:52 -0500
Newsgroups alt.comp.os.windows-10,alt.comp.os.windows-11,alt.comp.microsoft.windows
Organization BWH Usenet Archive (https://usenet.blueworldhosting.com)
Message-ID <[email protected]>
Carlos E. R. wrote:
>> When you copy text from any Chromium-based application, Apparently Windows
>> does not just copy plain text. Windows actually puts two versions of the
>> text on the Windows clipboard:
>> 1. a normal plain-text version
>> 2. a hidden HTML-formatted version
> 
> This is a very old Windows feature. It is up to the receiving 
> application to choose what version to paste.
> 
> With a clipboard manager perhaps you can choose the version yourself.

Hi Carlos,

Thanks for pointing that out as this artifact has been biting me because I
really never understood how the characters are stored in the clipboard.

I believe that you are absolutely right that Windows has supported multiple
clipboard formats for a long time and that applications are free to
offer several representations of the same data. That part is completely
normal, and your reminder helps me double-check that angle while I was
debugging this.

The part that took me a while to uncover is what Chromium-based
applications actually place on the clipboard. They do not just provide
plain text. They also provide a CF_HTML fragment with StartFragment and
EndFragment markers. That HTML fragment is what Notepad++ ends up choosing
when pasting.

Once Notepad++ sees that HTML fragment, it switches into what apparently
some people call "HTML fragment mode". In that mode, the editor treats the
first line of the buffer as a fragment boundary. That boundary is invisible
in the editor, but it affects selection logic. 

As a result:
a. Ctrl+A flashes but does not select the entire document
b. Hence, Ctrl+X does nothing because selections behave incorrectly

This happens even in a brand-new, unsaved buffer with no BOM and no
encoding issues. Surprisingly, the Notepad++ hex editor will not show
anything unusual because the artifact is not in the pasted text itself. 

The artifact is actually in the clipboard metadata that Chromium adds.

The workaround (inserting and then deleting a blank line at the top) forces
Notepad++ to abandon HTML fragment mode and treat the buffer as plain text
again. After that, Ctrl+A and Ctrl+X work normally. Ask me how I know this. 

So yes, Windows is behaving as designed by offering multiple clipboard
formats and your point about applications choosing which format to paste is
correct. The unexpected part for me is that Notepad++ selects the HTML
flavor from Chromium and then Notepad++ enters a special mode that breaks
normal selection behavior.

Your comment helped me frame the explanation more clearly, so thanks for
that useful added value, which is why we're all here on Usenet. To learn.
-- 
Every Usenet post should strive to add palpable additional value
so that we can all delight in dissemination of useful knowledge.