Click here to Skip to main content
15,940,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
I think it's a very basic question, but I'm stuck with it. When we copy text from a webpage and paste it in notepad, no HTML Markup gets pasted, only the plain text gets there. How, notepad handles it and removes the markup, but if we paste the same thing in any rich text editor like Office Word, we can see that the markup gets there (all the formatting links etc are intact).

It will be your great help if someone puts some light on it
Updated 25-Oct-20 17:55pm

Simply right click your web page, then view source finally copy the content and paste it into notepad.
Share this answer
senguptaamlan 3-Oct-12 8:22am    
I think U didn't got my problem, it's my bad. I was asking how notepad strips off the HTML markup when we copy content from a webpage and paste it in a notepad.
Guirec 3-Oct-12 8:33am    
It is actually not stripping the html off... but it uses the "plain text" flavor of the Clipboard while Word is using the "rich text" flavor...
If you want to strip html tags you can do this in c# using a regular expression. Something like:

public static string RemoveTags(string html)
return Regex.Replace(html, "<.*?>", string.Empty);
Guirec Le Bars seems to be correct in explaining the difference between how word will interpret the copied data from the web page and notepad wont..

You cannot get on notepad by copying directly as notepad cant render the rich text as its just plain text file...

And even if you copy paste from the view source and then copy the content in notepad it would just show the tags and text and cant render or to say "Cant Style them Or Say cannot provide formatting"
For reason one its just plain text you cannot get Rich text experience in notepad ..
It copies text from html . In notepad the attributes or html tags are ignored while word file can render them just copying from html page to Notepad .txt file will ignore all the tags while word shows the "almost" accurate styling as in html tags .. Almost Because there are few characters it wont understand and may give some inconsistency.
Share this answer
senguptaamlan 4-Oct-12 8:30am    
my expectation was a bit more....I was thinking about whats the internal logic that notepad executes while we make the paste operation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900