0% found this document useful (0 votes)
175 views13 pages

Creating HTML Headings in TextEdit

The document provides instructions for creating a basic HTML page using a simple text editor like Notepad or TextEdit. It includes 4 steps: 1) Open the text editor, 2) Write some HTML code for a basic page, 3) Save the HTML file, and 4) View the page in a web browser. The document also provides examples of basic HTML tags for headings, paragraphs, and horizontal rules.

Uploaded by

vaishali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
175 views13 pages

Creating HTML Headings in TextEdit

The document provides instructions for creating a basic HTML page using a simple text editor like Notepad or TextEdit. It includes 4 steps: 1) Open the text editor, 2) Write some HTML code for a basic page, 3) Save the HTML file, and 4) View the page in a web browser. The document also provides examples of basic HTML tags for headings, paragraphs, and horizontal rules.

Uploaded by

vaishali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Learn HTML Using Notepad or TextEdit

Web pages can be created and modified by using professional HTML editors.

However, for learning HTML we recommend a simple text editor like Notepad (PC) or
TextEdit (Mac).

We believe in that using a simple text editor is a good way to learn HTML.

Follow the steps below to create your first web page with Notepad or TextEdit.

Step 1: Open Notepad (PC)

Open the Start Screen (the window symbol at the bottom left on your screen).
Type Notepad.

Windows 7 or earlier:

Open Start > Programs > Accessories > Notepad

Step 1: Open TextEdit (Mac)

Open Finder > Applications > TextEdit

Also change some preferences to get the application to save files


correctly. In Preferences > Format > choose "Plain Text"

Then under "Open and Save", check the box that says "Display HTML files as HTML
code instead of formatted text".

Then open a new document to place the code.

Step 2: Write Some HTML


Write or copy the following HTML code into Notepad:

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>
Step 3: Save the HTML Page
Save the file on your computer. Select File > Save as in the Notepad menu.

Name the file "[Link]" and set the encoding to UTF-8 (which is the


preferred encoding for HTML files).

Tip: You can use either .htm or .html as file extension. There is no difference,
it is up to you.

Step 4: View the HTML Page in Your Browser


Open the saved HTML file in your favorite browser (double click on the file, or
right-click - and choose "Open with").

The result will look much like this:


With our free online editor, you can edit the HTML code and view the result in
your browser.

It is the perfect tool when you want to test code fast. It also has color coding
and the ability to save and share code with others:

Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>This is a Heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Output

This is a Heading

This is a paragraph.
HTML Basic Examples
HTML Documents

All HTML documents must start with a document type declaration: <!DOCTYPE html>.

The HTML document itself begins with <html> and ends with </html>.

The visible part of the HTML document is between <body> and </body>.

Example
<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>


<p>My first paragraph.</p>

</body>
</html>

The <!DOCTYPE> Declaration

The <!DOCTYPE> declaration represents the document type, and helps browsers


to display web pages correctly.

It must only appear once, at the top of the page (before any HTML tags).

The <!DOCTYPE> declaration is not case sensitive.

The <!DOCTYPE> declaration for HTML5 is:

[Link] Headings
HTML headings are defined with the <h1> to <h6> tags.

<h1> defines the most important heading. <h6> defines the least important


heading: 

Example

<!DOCTYPE html>

<html>

<body>

<h1>This is heading 1</h1>

<h2>This is heading 2</h2>

<h3>This is heading 3</h3>


<h4>This is heading 4</h4>

<h5>This is heading 5</h5>

<h6>This is heading 6</h6>

</body>

</html>

Output

This is heading 1

This is heading 2
This is heading 3

This is heading 4

This is heading 5

[Link] Paragraphs
HTML paragraphs are defined with the <p> tag:

Example

<!DOCTYPE html>

<html>

<body>

<p>This is a paragraph.</p>

<p>This is another paragraph.</p>

</body>

</html>

Output

This is a paragraph.

This is another paragraph.


HTML Display
You cannot be sure how HTML will be displayed.

Large or small screens, and resized windows will create different results.

With HTML, you cannot change the display by adding extra spaces or extra
lines in your HTML code.

The browser will automatically remove any extra spaces and lines when the
page is displayed:

Example

<!DOCTYPE html>

<html>

<body>

<p>

This paragraph

contains a lot of lines

in the source code,

but the browser

ignores it.

</p>

<p>

This paragraph

contains a lot of spaces

in the source code,

but the browser

ignores it.

</p>

<p>

The number of lines in a paragraph depends on the size of the browser


window. If you resize the browser window, the number of lines in this
paragraph will change.
</p>

</body>

</html>

Output

This paragraph contains a lot of lines in the source code, but the browser ignores it.

This paragraph contains a lot of spaces in the source code, but the browser ignores
it.

The number of lines in a paragraph depends on the size of the browser window. If
you resize the browser window, the number of lines in this paragraph will change.

HTML Horizontal Rules


The <hr> tag defines a thematic break in an HTML page, and is most often
displayed as a horizontal rule.

The <hr> element is used to separate content (or define a change) in an HTML


page:

Example

<!DOCTYPE html>

<html>

<body>

<h1>This is heading 1</h1>

<p>This is some text.</p>

<hr>

<h2>This is heading 2</h2>

<p>This is some other text.</p>

<hr>

<h2>This is heading 2</h2>

<p>This is some other text.</p>

</body>

</html>
Output

This is heading 1

This is some text.

This is heading 2
This is some other text.

This is heading 2
This is some other text.

HTML Line Breaks


The HTML <br> element defines a line break.

Use <br> if you want a line break (a new line) without starting a new
paragraph:

Example

<!DOCTYPE html>

<html>

<body>

<p>This is<br>a paragraph<br>with line breaks.</p>

</body>

</html>

Output
This is
a paragraph
with line breaks.
[Link] Styles

The HTML style attribute is used to add styles to an element, such as


color, font, size, and more.

Example
<!DOCTYPE html>

<html>

<body>

<p>I am normal</p>

<p style="color:red;">I am red</p>

<p style="color:blue;">I am blue</p>

<p style="font-size:50px;">I am big</p>

</body>

</html>

Output

I am normal

I am red

I am blue

I am big
The HTML Style Attribute
Setting the style of an HTML element, can be done with the style attribute.

The HTML style attribute has the following syntax:

Setting the style of an HTML element, can be done with the style attribute.

The HTML style attribute has the following syntax:

<tagname style="property:value;">
Background Color
The CSS background-color property defines the background color for an HTML
element.

Example
Set the background color for a page to powderblue:

Example
<!DOCTYPE html>
<html>
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>

Output
Text Color
The CSS color property defines the text color for an HTML element:

Example
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>
Output

This is a heading

This is a paragraph.

Fonts
The CSS font-family property defines the font to be used for an HTML element:

<!DOCTYPE html>
<html>
<body>
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
</body>
</html>

Output

This is a heading

This is a paragraph.
Text Size
The CSS font-size property defines the text size for an HTML element:

Example
<!DOCTYPE html>
<html>
<body>
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
</body>
</html>
Output

This is a heading
This is a paragraph.

HTML Exercise
Example 1)
Use the correct HTML tag to add a heading with the text "London".

<p>London is the capital city of England. It is the most populous city in the United
Kingdom, with a metropolitan area of over 13 million inhabitants.</p>

Example 2)

Use the correct HTML tag to add a paragraph with the text "Hello World!".

<html>
<body>

</body>
</html>
Example 3)
Clean up this document with proper end tags.

<h1>This is a Heading

<p>This is a paragraph.

Example 4)
Add a horizontal rule between the heading and the paragraph.

<h1>London</h1>

<p>London is the capital city of England. It is the most


populous city in the United Kingdom, with a metropolitan area
of over 13 million inhabitants.</p>

Example 5)
Use the correct HTML attribute, and CSS, to set the color of the paragraph to
"blue".

<p  =" ;">This is a paragraph.</p>

You might also like