Text Editors for HTML and Script Editing
Web pages (HTML files) and scripts (such as PHP or CGI/PERL scripts) must be saved as plain text (sometimes called ASCII) files. But plain text is not so plain; there are many different formats (encodings) for plain text files. Another factor is the way the end of a line is indicated. There are three styles of line endings: Unix/Mac OSX, Mac OS9, and DOS/Windows.
Text formats for HTML files
The recommended encoding format for HTML files is a Unicode format known as UTF-8. But be careful when saving as UTF-8: some text editors (such as NotePad) will automatically insert a byte order mark (BOM) at the very beginning of a UTF-8 file, but the presence of a BOM may cause problems with some browsers and should be avoided. It does not matter what kind of line endings are used in an HTML file.
Text formats for scripts (such as PHP and PERL files)
Many of the different plain text formats will work for script files, but the important factor for scripts that will be installed on a Unix/Linux Web server is the line-ending style. These script files must use Unix line endings, or the script will not run. Additionally, the presence of a byte order mark (BOM) may interfere with the script and should be avoided.
Text editor requirements
To properly code HTML, and to edit PHP and CGI scripts, you want a text editor that:
- Saves a file as UTF-8, without a byte order mark (BOM).
- Web pages saved as UTF-8 with a BOM will work in most browsers and will validate, but the validator will warn you that some browsers may have problems with the BOM. Scripts must be saved without a BOM.
- Saves a file with Unix line endings.
- Web pages can be saved with Unix/Mac OSX, Mac OS9, or DOS/Windows line endings, but scripts (that will be installed on a Unix/Linux Web server) must be saved with Unix line endings.
You have a few options as to which text editor application to use. Unfortunately none of the free text editors that comes with Macintosh and Windows operating systems is ideal for both HTML and script editing.
Macs come with a text editor called TextEdit, which defaults to saving files as RTF (rich text format), but if you change the defaults (instructions below) it will work for HTML and script editing. Windows comes with two text editors, NotePad and WordPad, but neither of these is ideal for our purposes. NotePad can save a file as UTF-8, but only with a byte order mark (BOM), and it only saves files with DOS/Windows line endings. WordPad can save a file with Unix line endings, but cannot save as UTF-8 without a BOM.
So the best thing to do is to download, install, and properly configure one of the text editors below.
Recommended free text editors
TextWrangler (Mac only)
TextWrangler is available as a free download from BareBones Software at:
If your Mac cannot run the latest version of TextWrangler, older versions may be downloaded at:
TextWrangler for proper HTML encoding and script editing, go to:
TextWrangler > Preferences > Text Encodings > Default text encoding for new documents
and choose "Unicode (UTF-8)" from the dropdown menu*. Then go to:
TextWrangler > Preferences > Text Files > Default line breaks
and select the "Unix (LF)" radio button.
*Note that in older versions of TextWrangler choose "Unicode (UTF-8, no BOM)".
To configure TextWrangler to wrap long lines, go
TextWrangler > Preferences > Editor Defaults
Check "Soft wrap text" to window width.
Notepad++ (Windows only)
Do not confuse Notepad++ with Notepad, the text editor that comes with Windows. Notepad++ is a different, much better text editor.
Notepad++ is available as a free downlaod at:
Click the "Download" link in the main menu, then click the link to download the current version.
To configure Notepad++ for proper HTML encoding and script editing, go to:
Settings > Preferences… > New Document > Encoding section
and select the "UTF-8" (not the "UTF-8 with BOM") radio button.
And put a check in the "Apply to opened ANSI files" checkbox.
Then on the same page go to the Format (line ending) sectiion
and select the "Unix/OSX" radio button.
Click the "Close" button to save your settings.
Other free text editors
jEdit (Windows, Linux, Mac)
jEdit is available as a free downlaod from jedit.org at:
If the jEdit installer tells you that you do not have a Java Runtime Environment
(JRE) on your computer, you will neet to download and install this
before you can install jEdit. You can download Java 2 Platform, Standard
Edition, v 1.4.2 (J2SE) from Sun at:
To configure jEdit for proper HTML encoding and script editing, go to:
jEdit > General > Default character encoding
and choose "UTF-8" from the dropdown menu. Then go to:
jEdit > General > Default line separator
and choose "Unix (\n)" from the dropdown menu.
Note: Be careful when choosing the character encoding to choose "UTF-8" (no BOM); do not choose "UTF-8Y" (which will create a BOM).
TextEdit* (Mac only)
TextEdit is already installed on every Mac running OS X.
*Important note: TextEdit saves new files with Unix line endings by default. But if you open an existing file that has other line ending styles, TextEdit will preserve them and will not change them to Unix line endings when you save the file. Be careful if using TextEdit for editing scripts!
To configure TextEdit for proper HTML encoding and script editing, go to:
TextEdit > Preferences > New Document > Format
and slect the "Plain text" button. Then go to:
TextEdit > Preferences > Open and Save > Plain Text File Encoding > Saving files
and choose "Unicode (UTF-8)" from the dropdown menu. Then go to:
TextEdit > Preferences > Open and Save > HTML Saving Options > Encoding
and choose "Unicode (UTF-8)" from the dropdown menu.