How To HTML
How To HTML
Tags Explained
The <!DOCTYPE html> declaration defines this document to be HTML5
The <html> element is the root element of an HTML page
The <head> element contains meta information about the document
The <title> element specifies a title for the document
The <body> element contains the visible page content
The <h1> element defines a large heading
The <p> element defines a paragraph
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).
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>
</body>
</html>
HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important
heading:
Example
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
HTML Paragraphs
HTML paragraphs are defined with the <p> tag:
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
HTML Links
HTML links are defined with the <a> tag:
Example
<a href="http://google.com ">This is a link</a>
HTML Images
HTML images are defined with the <img> tag.
The source file (src), alternative text (alt), width, and height are provided as
attributes:
Example
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
HTML Colors
In HTML, a color can be specified by using a color name, an RGB value, or
a HEX value.
Color Names
In HTML, a color can be specified by using a color name:
Example
Color Name
Red
Orange
Yellow
Cyan
Blue
RGB Value
In HTML, a color can also be specified as an RGB value, using this formula:
rgb(red, green, blue)
Each parameter (red, green, and blue) defines the intensity of the color
between 0 and 255.
To display the color black, all color parameters must be set to 0, like this:
rgb(0,0,0).
To display the color white, all color parameters must be set to 255, like this:
rgb(255,255,255).
Experiment by mixing the RGB values below:
255 0 0
rgb(255, 0, 0)
Example
Color RGB
rgb(255,0,0)
rgb(255,255,0)
rgb(0,255,0)
rgb(0,255,255)
rgb(0,0,255)
Try it Yourself
Shades of gray are often defined using equal values for all the 3 light
sources:
Example
Color RGB
rgb(0,0,0)
rgb(90,90,90)
rgb(128,128,128)
rgb(200,200,200)
rgb(255,255,255)
Try it Yourself
HEX Value
In HTML, a color can also be specified using a hexadecimal value in the form:
#RRGGBB, where RR (red), GG (green) and BB (blue) are hexadecimal
values between 00 and FF (same as decimal 0-255).
For example, #FF0000 is displayed as red, because red is set to its highest
value (FF) and the others are set to the lowest value (00).
Example
Color HEX
#FF0000
#FFFF00
#00FF00
#00FFFF
#0000FF
Shades of gray are often defined using equal values for all the 3 light
sources:
Example
Color HEX
#000000
#404040
#808080
#CCCCCC
#FFFFFF