Beruflich Dokumente
Kultur Dokumente
Ref Guide
Put Into Knowledge
Author
Mithilesh Kumar
Copyright @ InventaTeq 1
What is HTML?
=========================================================
HTML Tags
==========================================================
HTML tags are keywords (tag names) surrounded by angle brackets like
<html>
The first tag in a pair is the start tag, the second tag is the end tag
The end tag is written like the start tag, with a forward slash before the tag
name
Start and end tags are also called opening tags and closing tags
<tagname>content</tagname>
Copyright @ InventaTeq 2
HTML Elements
==========================================================
"HTML tags" and "HTML elements" are often used to describe the same
thing.
But strictly speaking, an HTML element is everything between the start tag
and the end tag, including the tags:
<p>This is a paragraph.</p>
Web Browsers
==========================================================
The browser does not display the HTML tags, but uses the tags to determine
how the content of the HTML page is to be presented/displayed to the user.
Adobe Dreamweaver
Copyright @ InventaTeq 3
However, for learning HTML we recommend a text editor like Notepad (PC)
or TextEdit (Mac). We believe using a simple text editor is a good way to learn
HTML.
Follow the 4 steps below to create your first web page with Notepad.
Start
All Programs
Accessories
Notepad
When you save an HTML file, you can use either the .htm or the .html file
extension. There is no difference, it is entirely up to you.
Start your web browser and open your html file from the File, Open menu, or
just browse the folder and double-click your HTML file.
Copyright @ InventaTeq 4
HTML Headings
==========================================================
Example
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
HTML Paragraphs
==========================================================
Example
<p>This is a paragraph.</p>
HTML Links
Example
HTML Images
==========================================================
Copyright @ InventaTeq 5
HTML images are defined with the <img> tag.
Example
* The start tag is often called the opening tag. The end tag is often called the
closing tag.
<!DOCTYPE html>
<html>
<body>
</body>
</html>
The element has a start tag <p> and an end tag </p>.
</body>
The element has a start tag <body> and an end tag </body>.
<html>
<body>
</body>
</html>
The element has a start tag <html> and an end tag </html>.
HTML Attributes
==========================================================
Copyright @ InventaTeq 7
Attributes come in name/value pairs like: name="value"
Attribute Example
HTML links are defined with the <a> tag. The link address is specified in the
href attribute:
Example
HTML Headings
<h1> defines the most important heading. <h6> defines the least important
heading.
Example
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
Use HTML headings for headings only. Don't use headings to make text BIG
or bold.
Search engines use your headings to index the structure and content of your
web pages.
Copyright @ InventaTeq 8
Since users may skim your pages by its headings, it is important to use
headings to show the document structure.
HTML Lines
==========================================================
Example
<p>This is a paragraph.</p>
<hr>
<p>This is a paragraph.</p>
<hr>
<p>This is a paragraph.</p>
HTML Paragraphs
==========================================================
Example
<p>This is a paragraph</p>
Copyright @ InventaTeq 9
<p>This is another paragraph</p>
==========================================================
Use the <br> tag if you want a line break (a new line) without starting a new
paragraph:
Example
=========================================================
HTML uses tags like <b> and <i> for formatting output, like bold or italic
text.
These HTML tags are called formatting tags (look at the bottom of this page
for a complete reference).
<strong> or <em> means that you want the text to be rendered in a way that
the user understands as "important". Today, all major browsers render
strong as bold and em as italics. However, if a browser one day wants to make
a text highlighted with the strong feature, it might be cursive for example and
not bold.
Copyright @ InventaTeq 10
HTML Comment Tags
==========================================================
You can add comments to your HTML source by using the following syntax:
Note: There is an exclamation point (!) in the opening tag, but not in the
closing tag.
Comments are not displayed by the browser, but they can help document your
HTML.
With comments you can place notifications and reminders in your HTML:
Example
<p>This is a paragraph.</p>
==========================================================
A hyperlink (or link) is a word, group of words, or image that you can click on
to jump to another document.
When you move the cursor over a link in a Web page, the arrow will turn into
a little hand.
Copyright @ InventaTeq 11
The most important attribute of the <a> element is the href attribute, which
indicates the link's destination.
Example
Tip: The "Link text" doesn't have to be text. It can be an image or any other
HTML element.
The example below will open the linked document in a new browser window
or a new tab:
Copyright @ InventaTeq 12
Example
Tip: Bookmarks are not displayed in any special way. They are invisible to the
reader.
Example
Create a link to the "Useful Tips Section" inside the same document:
Or, create a link to the "Useful Tips Section" from another page:
<a href="http://www.ABC.com/html_links.htm#tips">
========================================================
The <head> element is a container for all the head elements. Elements inside
<head> can include scripts, instruct the browser where to find style sheets,
provide meta information, and more.
The following tags can be added to the head section: <title>, <style>, <meta>,
<link>, <script>, <noscript>, and <base>.
Copyright @ InventaTeq 13
The HTML <title> Element
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
The <base> tag specifies the base URL/target for all relative URLs in a page:
Copyright @ InventaTeq 14
<head>
</head>
The <link> tag defines the relationship between a document and an external
resource.
<head>
</head>
The <style> tag is used to define style information for an HTML document.
Inside the <style> element you specify how HTML elements should render in
a browser:
<head>
<style type="text/css">
body {background-color:yellow;}
p {color:blue;}
</style>
</head>
Copyright @ InventaTeq 15
The HTML <meta> Element
==========================================================
The <meta> tag provides metadata about the HTML document. Metadata will
not be displayed on the page, but will be machine parsable.
Copyright @ InventaTeq 16
<meta http-equiv="refresh" content="30">
==========================================================
CSS was introduced together with HTML 4, to provide a better way to style
HTML elements.
The preferred way to add CSS to HTML, is to put CSS syntax in separate
CSS files.
Inline Styles
======================================================
To use inline styles, use the style attribute in the relevant tag. The style
attribute can contain any CSS property. The example below shows how to
change the text color and the left margin of a paragraph:
Copyright @ InventaTeq 17
Example
<!DOCTYPE html>
<html>
<body style="background-color:yellow;">
</body>
</html>
Example
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
</body>
</html>
<head>
<style>
body {background-color:yellow;}
p {color:blue;}
</style>
</head>
An external style sheet is ideal when the style is applied to many pages. With
an external style sheet, you can change the look of an entire Web site by
changing one file. Each page must link to the style sheet using the <link> tag.
The <link> tag goes inside the <head> section:
<head>
</head>
Tag Description
Copyright @ InventaTeq 19
<link> Defines the relationship between a document and an
external resource
==========================================================
In HTML 4, several tags and attributes were used to style documents. These
tags are not supported in newer versions of HTML.
Avoid using the elements: <font>, <center>, and <strike>, and the attributes:
color and bgcolor.
The font-family, color, and font-size properties defines the font, color, and size
of the text in an element:
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
The <img> tag is empty, which means that it contains attributes only, and has
no closing tag.
To display an image on a page, you need to use the src attribute. Src stands
for "source". The value of the src attribute is the URL of the image you want
to display.
The URL points to the location where the image is stored. An image named
"boat.gif", located in the "images" directory on "www.ABC.com" has the
URL: http://www.ABC.com/images/boat.gif.
The browser displays the image where the <img> tag occurs in the document.
If you put an image tag between two paragraphs, the browser shows the first
paragraph, then the image, and then the second paragraph.
The required alt attribute specifies an alternate text for an image, if the image
cannot be displayed.
The alt attribute provides alternative information for an image if a user for
some reason cannot view it (because of slow connection, an error in the src
attribute, or if the user uses a screen reader).
Copyright @ InventaTeq 21
HTML Images - Set Height and Width of an Image
The height and width attributes are used to specify the height and width of an
image.
HTML Tables
==========================================================
A table is divided into rows with the <tr> tag. (tr stands for table row)
A row is divided into data cells with the <td> tag. (td stands for table data)
A row can also be divided into headings with the <th> tag. (th stands for table
heading)
The <td> elements can contain all sorts of HTML elements like text, images,
lists, other tables, etc.
Example
<table style="width:300px">
<tr>
<td>Jill</td>
Copyright @ InventaTeq 22
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
If you do not specify a border for the table, it will be displayed without
borders.
Example
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
Copyright @ InventaTeq 23
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
==========================================================
An unordered list starts with the <ul> tag. Each list item starts with the <li>
tag.
The list items are marked with bullets (typically small black circles).
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
Coffee
Milk
==========================================================
Copyright @ InventaTeq 24
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
Coffee
Milk
The <dl> tag is used in conjunction with <dt> (defines terms/names) and <dd>
(describes each term/name):
<dl>
<dt>Coffee</dt>
<dt>Milk</dt>
Copyright @ InventaTeq 25
</dl>
Coffee
Milk
HTML Forms
An HTML form can contain input elements like text fields, checkboxes, radio-
buttons, submit buttons and more. A form can also contain select lists,
textarea, fieldset, legend, and label elements.
<form>
input elements
</form>
An <input> element can vary in many ways, depending on the type attribute.
An <input> element can be of type text field, checkbox, password, radio
button, submit button, and more.
Copyright @ InventaTeq 26
The most common input types are described below.
Text Fields
==========================================================
<input type="text"> defines a one-line input field that a user can enter text
into:
<form>
</form>
Password Field
<form>
</form>
Radio Buttons
<input type="radio"> defines a radio button. Radio buttons let a user select
ONLY ONE of a limited number of choices:
<form>
Copyright @ InventaTeq 27
</form>
Male
Female
Checkboxes
<form>
</form>
I have a bike
I have a car
Submit Button
A submit button is used to send form data to a server. The data is sent to the
page specified in the form's action attribute. The file defined in the action
attribute usually does something with the received input:
Copyright @ InventaTeq 28
<form name="input" action="demo_form_action.asp" method="get">
</form>
Color Values
CSS colors are defined using a hexadecimal (hex) notation for the
combination of Red, Green, and Blue color values (RGB). The lowest value
that can be given to one of the light sources is 0 (hex 00). The highest value is
255 (hex FF).
Hex values are written as 3 double digit numbers, starting with a # sign.
Color Examples
#000000 rgb(0,0,0)
#FF0000 rgb(255,0,0)
#00FF00 rgb(0,255,0)
#0000FF rgb(0,0,255)
#FFFF00 rgb(255,255,0)
#00FFFF rgb(0,255,255)
Copyright @ InventaTeq 29