PSA: Don't open HTML files as text in text edit if you want to do more editing to them.

By Levi Gobin, 23 January, 2025

Forum
macOS and Mac Apps

Be careful when opening HTML files as text in text edit.
I was working on a document, and I accidentally did that. Take this html text for example:

<p>This is a paragraph.
<br>
That is a line break</p>
<h1>This is a heading</h1>
<ul><li>This is a list</li></ul>

Text edit turned that, into this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="2575.4">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 12.0px 0.0px; font: 12.0px Times; -webkit-text-stroke: #000000}
li.li3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times; -webkit-text-stroke: #000000}
span.s1 {font-kerning: none}
span.s2 {-webkit-text-stroke: 0px #000000}
ul.ul1 {list-style-type: disc}
</style>
</head>
<body>
<p class="p1"><span class="s1">This is a paragraph. <br>
That is a line break.</span></p>
<h1 style="margin: 0.0px 0.0px 16.1px 0.0px; font: 24.0px Times; -webkit-text-stroke: #000000"><span class="s1"><b>This is a heading.</b></span></h1>
<ul class="ul1">
<li class="li3"><span class="s2"></span><span class="s1">This is a list</span></li>
</ul>
</body>
</html>

so, be careful! If this has happened to you, my best bet is to just use find/replace.
It'll probably take you a bit, but it can be done.
If you want to disable this behavier, open the preferences for text edit, and on the open/saveing tab, make sure that Display HTML files as HTML code instead of formatted text is checked. This should get rid of that.
Thought I would just let you know.

Options

Comments

By Brian on Thursday, January 23, 2025 - 20:26

Wow that is an old article. Good read though. 😜

By TheBllindGuy07 on Thursday, January 23, 2025 - 20:26

Actually my link was 101% useless I was just curious where this came from in the head :)

By Levi Gobin on Thursday, January 23, 2025 - 20:26

Was just giving you a little warning about making sure you check that box. It really annoyed me when I was working on a project earlier to the point where I felt like stopping

By Brian on Thursday, January 23, 2025 - 21:26

Ohh, TheBllindGuy07 ... (tsk tsk)
You have really got to learn to read more thoroughly, before you respond.
Not once did I say it was useful. I simply said it was a good read, and I also hinted that it was incredibly old in my subject above.
Ah well, no cookie for you. 🙂‍↔️

By TheBllindGuy07 on Thursday, January 23, 2025 - 22:26

And where did I imply that? :) Also, there are more than enough cookies on the internet for everyone and I think we can happily agree on that 😂 Let's have a cookie session together. Make sure it's the first line of code, no BOM, after the start. Because otherwise there won't be any session. Feel free to cancel me for this infinitely times repeated joke. 777 for everyone.