HTML
HTML
HTML
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Example Explained
The <!DOCTYPE html> declaration defines that this document is an
HTML5 document
The <html> element is the root element of an HTML page
The <head> element contains meta information about the HTML page
The <title> element specifies a title for the HTML page (which is
shown in the browser's title bar or in the page's tab)
The <body> element defines the document's body, and is a container for
all the visible contents, such as headings, paragraphs, images,
hyperlinks, tables, lists, etc.
The <h1> element defines a large heading
The <p> element defines a paragraph
What is an HTML Element?
An HTML element is defined by a start tag,
some content, and an end tag:
- Follow the steps below to create your first web page with
Notepad or TextEdit.
Step 1: Open Notepad (PC)
Windows 8 or later:
Windows 7 or earlier:
<!DOCTYPE html>
<html>
<body>
</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 "index.htm" and set the encoding to UTF-8 (which is the
preferred encoding for HTML files).
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 HTML document itself begins with <html> and ends with
</html>.
Example:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
HTML Headings
It must only appear once, at the top of the page (before any HTML
tags).
Example:
Example:
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
HTML Paragraphs
HTML Images
The source file (src), alternative text (alt), width, and height are
provided as attributes:
Example:
Example:
<p>This is a <br> paragraph with a line break.</p>
Output:
This is a
paragraph with a line break.
Empty HTML Elements
Nested HTML Elements
HTML elements can be nested (this means that elements can contain other
elements). All HTML documents consist of nested HTML elements. The
following example contains four HTML elements (<html>, <body>, <h1> and
<p>):
HTML Styles
The HTML style attribute is used to add styles to an element, such as color,
font, size, and more.
HTML Styles
Background Color
The CSS color property defines the text color for an HTML element:
Text Color
Fonts
The CSS font-family property defines the font to be used for an HTML element:
Fonts
Text Alignment
The CSS text-align property defines the horizontal text alignment for an HTML
element:
Text Alignment
Chapter Summary
The HTML <b> element defines bold text, without any extra
importance.
HTML <b> and <strong> Elements