Textedit Save As Html

Today we are going to write and save our first CSS file. Let’s begin by opening a text editing program. If you are on a Microsoft Windows PC open the program named Notepad (hold down the Windows Key on your keyboard and press R, then type notepad and press enter). If you are using a Macintosh computer, launch the application named “TextEdit” (which can be found in your Apps folder).

Let’s Write Our First Bit of CSS

By default, there are two problems when you try to open html files on a Mac:1. When you double click it opens in Safari = annoying!2. Even if you right clic. From the TextEdit menubar, select File/Save As. In the Save As dialog box, give your file a name and hard disk location. Then, change the File Format selection to HTML, and click Save. Change how HTML files are saved In the TextEdit app on your Mac, choose TextEdit Preferences, then click Open and Save. Below HTML Saving Options, choose a document type, a style setting for CSS, and an encoding. Select “Preserve white space” to include code that preserves blank areas in.

HtmlTextedit save as html

Let’s imagine we have a simple web page with a heading, and we want the heading to be orange and center aligned. Add the following code into your new blank text document:

Hopefully, you remember this code from our previous lesson. The task for today is to save our CSS file and link it to an HTML page.

Textedit Export Html

Step 1: Saving The CSS File

Textedit Html Download

Create a new folder on your desktop (or another location you prefer) and name it CSS-Test. Now, back in your text editing program save your document as “style.css”.

Linking CSS File to an HTML Page

Our new CSS file is worthless if we don’t apply it to a web page. Let’s create a quick HTML page for this lesson. Create a new blank file in Notepad (or TextEdit) and add the following code:

If you’ve read my first few HTML Lessons, then this code is at least somewhat familiar. I’ll explain it as the lesson continues; for now save this document in our “CSS-Test” folder and name it “index.htm”.

Textedit On Mac

Linking the Two Files Together

We still need to tell the web browser to load our “style.css” file when the “index.htm” page is viewed. Add the following code to “index.htm” directly above our </head> closing tag:

This line of code tells our browser that we want to link a Style Sheet, that it’s located in the same folder as our HTML page, and that it’s named “style.css”.

Txt File On Mac

Now, when you view “index.htm” page in a web browser you should see a centered, orange heading:

Let’s Style Those Two Boxes

If you look at the code of our HTML page, you’ll see two <div> elements. We added an HTML attribute of “id” for these two elements and assigned them values of “box-one” and “box-two.” We can use an element’s “id” to select and style it with CSS. For example, let’s make the first box gray, and the second box yellow. Add the following code to your CSS file, directly below our original <h1> rule:

Textedit

When an element has an “id” we can access it with a CSS selector by placing a pound sign (#) in front of it’s id value. So to select the first <div> element we simply type “#box-one” and then begin our CSS Rule.

Our New Fancy Boxes

When you save your CSS file and refresh our HTML page in a web browser you should see something very similar to this:

Textedit Save As Html

Yay For Style

It may not be beautiful, but we styled our first HTML page with CSS! Let’s recap your CSS knowledge so far. You know:

  • The basic syntax of CSS (covered in our previous lesson)
  • How to link a CSS file to an HTML page
  • How to select certain HTML elements and style them

Textedit Document

In our next lesson we’ll continue learning about CSS Selectors and the different ways to target specific elements with your CSS.

Textedit save as html converter

Textedit Save As Html File

If you prefer to watch video lessons instead of reading written lessons check out my 8 hour video course and join 4,000+ others who have learned pro-level HTML, CSS, and responsive design.