Introduction to HTML
- HTML Overview
- HyperText Markup Language is the primary language for building/creating web pages.
- HTML uses markup tags which describe or define content in a Web document. (It is not a scripting or a programming language)
- HTML documents contain HTML tags and plain text which are often simply called web pages.
- HTML code is often referred to as source code.
- HTML can be coded using a plain text editor.
- When using a text editor, save the HTML document using the file extension .html or .htm
- Rules for HTML tags (syntax)
- HTML tags are enclosed inside angle brackets: < >.
- The tag name is keyed between the two angle brackets. Example: <body>.
- With a few exceptions, tags occur in pairs with an opening and a closing Example <body> </body>
- The opening <body> indicates the start of the body section and the closing </body> marks the end of the body section.
- The forward slash (/) always precedes the tag name in a closing tag. The closing tag is written like the start tag but with the forward slash before the tag name. </body>
- The text between the HTML tags is keyed in plain text
- The following tags do not have pairs and are often called “empty tags”: <br>, <hr>, <img>, <meta> (These tags do not have information that you would put between an opening and closing tag)
- While HTML tags are not case sensitive, they are generally keyed in all lowercase
- An HTML element consists of everything between the start tag and the end tag including the tags. For example: <h1>This is heading style 1</h1>
- An HTML attribute gives elements additional meaning and context. For example: <img src=”team.jpg” alt=”team photo”>
- The image tag requires the src (source) attribute and the alt (alternative) attribute. The required alt attribute specifies an alternate text for an image, if the image cannot be displayed. The user defines the text in the alt tag.
-
Attributes - provide additional information about tags and control how the tag will be interpreted by the browser.
- Tags can have multiple attributes.
- Attributes have syntax rules:
- Attributes are entered inside the opening tag but not in the closing tag.
- Attributes are keyed in name/value Syntax: name=”value”
- The attribute should have an equal symbol followed by the value or setting for the attribute.
- Attribute values are enclosed within quotation marks.
- In HTML5 there is a single doctype declaration <!DOCTYPE html>. The doctype is not technically an HTML tag. It is simply a declaration that tells the web browser the version of html in the document.
- An HTML document consists of two sections the <head> and the <body>.
- The <body> is the visible content of the web document.
- The <head> section contains information about the page.
- For example the <title> displays in the web browser title bar—not in the actual web document. The title must be in the <head> section.
- The <meta> tag provides additional information about the document.
- Internal and External CSS files are referenced in the <head> section.
- HTML tag structure and nesting of tags is illustrated in the graphic shown below. Most html elements can be nested which means they can contain other html tags.
- HTML 5 and Audio
- HTML 5 introduced a standard way to embed an audio file on a web page using the <audio> tag.
- The <audio> element allows multiple <source> elements. <source> elements can link to different audio files. The browser will use the first recognized format.
- Currently, there are 3 supported file formats for the <audio> element: MP3, Wav, and Ogg
- HTML 5 and Video
- HTML5 defines a new element which specifies a standard way to embed a video/movie on a web page: the <video> element.
- The <video> element allows multiple <source> elements. <source> elements can link to different video files. The browser will use the first recognized format.
- Currently, there are 3 supported video formats for the <video> element: MP4, WebM, and Ogg
- The purpose of the <object> element is to support HTML helpers (plug-ins). Plug-ins are often used by browsers to play audio and video. Examples of well-known plug-ins are Adobe Flash Player and QuickTime. Plug-ins can be added to Web pages through the <object> tag or the <embed> tag.
- There are a total of 30 tags introduced and they are in two sections:
First Set of 18 HTML Tags |
|
HTML Tag |
Description |
<html> |
Defines the root of an HTML document |
<head> |
Defines information about the document |
<title> |
Defines a title for the document. The title appears in the browser; not in the web page. The title must be in the head section. |
<body> |
Defines the document's body; the visible content. |
<p> |
Defines a paragraph |
<img src=> |
Image Tag; Defines an image; src is a required attribute. |
<a href=> |
Anchor tag; Defines a hyperlink; href is a required attribute |
<hr> |
Horizontal rule; Defines a thematic change in the content |
<br> |
Break tag; Defines a single line break |
6 Heading styles |
|
<h1> |
Defines HTML headings; heading style 1 is the largest relative to the others |
<h2> |
Defines HTML headings |
<h3> |
Defines HTML headings |
<h4> |
Defines HTML headings |
<h5> |
Defines HTML headings |
<h6> |
Defines HTML headings; heading style 6 is the smallest relative to others |
List Elements-Numbered and Bulleted |
|
<ol> |
Defines an ordered list |
<ul> |
Defines an unordered list |
<li> |
Defines a list item |
- Next 12 Tags to Introduce
HTML Tag |
Description |
Multimedia Elements |
|
<audio> |
Defines sound content |
<video> |
Defines a video or movie |
<embed> |
Defines a container for an external (non-HTML) application |
<object> |
Defines an embedded object |
Head Elements |
|
<style> |
Defines style information for a document |
<link> |
Defines the relationship between a document and an external resource |
<meta> |
Defines metadata about an HTML document |
HTML Layouts |
|
<div> |
Defines a section in a document (block-level) |
<span> |
Defines a section in a document (inline) |
Structural Elements |
|
<header> |
Defines a header for a document or section |
<footer> |
Defines a footer for a document or section |
Html comment |
|
<!--put comment text here--> |