Social Icons

HTML

HTML5 Tutorial


What is HTML?

HTML is the standard markup language for creating Web pages.

    HTML stands for Hyper Text Markup Language
    HTML describes the structure of Web pages using markup
    HTML elements are the building blocks of HTML pages
    HTML elements are represented by tags
    HTML tags label pieces of content such as "heading", "paragraph", "table", and so on
    Browsers do not display the HTML tags, but use them to render the content of the page



Basic Format

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

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

</body>
</html>

Result:







Example 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



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

<!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>



Result:

This is heading 1

This is heading 2

This is heading 3

This is heading 4

This is heading 5
This is heading 6
 
 

HTML 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>
 

Result:

This is a paragraph.
This is another paragraph.


HTML Links

HTML links are defined with the <a> tag:

Example:

<!DOCTYPE html>
<html>
<body>

<a href="https://www.facebook.com">This is a link</a>

</body>
</html>

Result:

This is a link

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

<!DOCTYPE html>
<html>
<body>

<img src="anything.jpg" alt="anything" width="104" height="142">

</body>
</html>

Result:

HTML Attributes:

Attributes provide additional information about HTML elements.

HTML Attributes

  • All HTML elements can have attributes
  • Attributes provide additional information about an element
  • Attributes are always specified in the start tag
  • Attributes usually come in name/value pairs like: name="value"

The lang Attribute

The language of the document can be declared in the <html> tag.
The language is declared with the lang attribute.
Declaring a language is important for accessibility applications (screen readers) and search engines:
<!DOCTYPE html>
<html lang="en-US">
<body>

...

</body>
</html>

 

The title Attribute

Here, a title attribute is added to the <p> element. The value of the title attribute will be displayed as a tooltip when you mouse over the paragraph:

Example

<!DOCTYPE html>
<html>
<body>

<h2>The title attribute</h2>

<p title="I'm a tooltip">
Mouse over this paragraph, to display the title attribute as a tooltip.
</p>

</body>
</html>

Result:

The title attribute

Mouse over this paragraph, to display the title attribute as a tooltip. 


The href Attribute

HTML links are defined with the <a> tag. The link address is specified in the href attribute:

Example

<!DOCTYPE html>
<html>
<body>

<a href="https://www.w3schools.com">This is a link</a>

</body>
</html>
 

Result:

This is a link 

 

Size Attributes

HTML images are defined with the <img> tag.
The filename of the source (src), and the size of the image (width and height) are all provided as attributes:

Example


<!DOCTYPE html>
<html>
<body>

<img src="anything.jpg" width="104" height="142">

</body>
</html>
 

Result:

 

 

 

The alt Attribute

The alt attribute specifies an alternative text to be used, when an image cannot be displayed.
The value of the attribute can be read by screen readers. This way, someone "listening" to the webpage, e.g. a blind person, can "hear" the element.

Example

 <!DOCTYPE html>
<html>
<body>

<img src="anything.jpg" alt="anything

" width="104" height="142">

</body>
</html>

Single or Double Quotes?

Double quotes around attribute values are the most common in HTML, but single quotes can also be used.
In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes:

 p title='John "ShotGun" Nelson'>
Or vice versa:
<p title="John 'ShotGun' Nelson">

HTML Attributes

Below is an alphabetical list of some attributes often used in HTML:
Attribute Description
alt Specifies an alternative text for an image, when the image cannot be displayed
disabled Specifies that an input element should be disabled
href Specifies the URL (web address) for a link
id Specifies a unique id for an element
src Specifies the URL (web address) for an image
style Specifies an inline CSS style for an element
title Specifies extra information about an element (displayed as a tool tip)



HTML Headings:


Format code of Headings:

<!DOCTYPE html>
<html>
<body>

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

</body>
</html>



Output:


Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

HTML Paragraphs :


Code of Paragraphs:



   <!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 Styles: 


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:
<tagname style="property:value;">
The property is a CSS property. The value is a CSS value.



HTML Background Color

The background-color property defines the background color for an HTML element.
This example sets the background color for a page to powderblue:

Example

<body style="background-color:powderblue;">

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

</body>

  

HTML Text Formatting :


HTML Formatting Elements

In the previous chapter, you learned about the HTML style attribute.
HTML also defines special elements for defining text with a special meaning.
HTML uses elements like <b> and <i> for formatting output, like bold or italic text.
Formatting elements were designed to display special types of text:
  • <b> - Bold text
  • <strong> - Important text
  • <i> - Italic text
  • <em> - Emphasized text
  • <mark> - Marked text
  • <small> - Small text
  • <del> - Deleted text
  • <ins> - Inserted text
  • <sub> - Subscript text
  • <sup> - Superscript text

HTML <b> and <strong> Elements

The HTML <b> element defines bold text, without any extra importance.

Example

<b>This text is bold</b>
Code:

<!DOCTYPE html>
<html>
<body>

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

<p><b>This text is bold.</b></p>

</body>
</html>

Output: 

This text is normal.
This text is bold.

The HTML <strong> element defines strong text, with added semantic "strong" importance.

Example

<strong>This text is strong</strong>

 <!DOCTYPE html><html><body>
<p>This text is normal.</p>
<p><strong>This text is strong.</strong></p>
</body></html>

Output: 

This text is normal.
This text is strong.



HTML Quotation and Citation Elements :


HTML <q> for Short Quotations

The HTML <q> element defines a short quotation.
Browsers usually insert quotation marks around the <q> element.

Example

<p>WWF's goal is to: <q>Build a future where people live in harmony with nature.</q></p>

  Code: 

<!DOCTYPE html>
<html>
<body>

<p>Browsers usually insert quotation marks around the q element.</p>

<p>WWF's goal is to: <q>Build a future where people live in harmony with nature.</q></p>

</body>
</html>

Output: 

Browsers usually insert quotation marks around the q element.
WWF's goal is to: Build a future where people live in harmony with nature.


HTML Comment Tags

You can add comments to your HTML source by using the following syntax:
<!-- Write your comments here -->


Notice that there is an exclamation point (!) in the opening tag, but not in the closing tag.

Note: Comments are not displayed by the browser, but they can help document your HTML source code.
With comments you can place notifications and reminders in your HTML:

Example

<!-- This is a comment -->

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

<!-- Remember to add more information here -->




HTML Colors: 


Color Names

In HTML, a color can be specified by using a color name:
Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
LightGray























Color NameHEXColorShadesMix
AliceBlue #F0F8FF ShadesMix
AntiqueWhite #FAEBD7 ShadesMix
Aqua #00FFFF ShadesMix
Aquamarine #7FFFD4 ShadesMix
Azure #F0FFFF ShadesMix
Beige #F5F5DC ShadesMix
Bisque #FFE4C4 ShadesMix
Black #000000 ShadesMix
BlanchedAlmond #FFEBCD ShadesMix
Blue #0000FF ShadesMix
BlueViolet #8A2BE2 ShadesMix
Brown #A52A2A ShadesMix
BurlyWood #DEB887 ShadesMix
CadetBlue #5F9EA0 ShadesMix
Chartreuse #7FFF00 ShadesMix
Chocolate #D2691E ShadesMix
Coral #FF7F50 ShadesMix
CornflowerBlue #6495ED ShadesMix
Cornsilk #FFF8DC ShadesMix
Crimson #DC143C ShadesMix
Cyan #00FFFF ShadesMix
DarkBlue #00008B ShadesMix
DarkCyan #008B8B ShadesMix
DarkGoldenRod #B8860B ShadesMix
DarkGray #A9A9A9 ShadesMix
DarkGrey #A9A9A9 ShadesMix
DarkGreen #006400 ShadesMix
DarkKhaki #BDB76B ShadesMix
DarkMagenta #8B008B ShadesMix
DarkOliveGreen #556B2F ShadesMix
DarkOrange #FF8C00 ShadesMix
DarkOrchid #9932CC ShadesMix
DarkRed #8B0000 ShadesMix
DarkSalmon #E9967A ShadesMix
DarkSeaGreen #8FBC8F ShadesMix
DarkSlateBlue #483D8B ShadesMix
DarkSlateGray #2F4F4F ShadesMix
DarkSlateGrey #2F4F4F ShadesMix
DarkTurquoise #00CED1 ShadesMix
DarkViolet #9400D3 ShadesMix
DeepPink #FF1493 ShadesMix
DeepSkyBlue #00BFFF ShadesMix
DimGray #696969 ShadesMix
DimGrey #696969 ShadesMix
DodgerBlue #1E90FF ShadesMix
FireBrick #B22222 ShadesMix
FloralWhite #FFFAF0 ShadesMix
ForestGreen #228B22 ShadesMix
Fuchsia #FF00FF ShadesMix
Gainsboro #DCDCDC ShadesMix
GhostWhite #F8F8FF ShadesMix
Gold #FFD700 ShadesMix
GoldenRod #DAA520 ShadesMix
Gray #808080 ShadesMix
Grey #808080 ShadesMix
Green #008000 ShadesMix
GreenYellow #ADFF2F ShadesMix
HoneyDew #F0FFF0 ShadesMix
HotPink #FF69B4 ShadesMix
IndianRed  #CD5C5C ShadesMix
Indigo  #4B0082 ShadesMix
Ivory #FFFFF0 ShadesMix
Khaki #F0E68C ShadesMix
Lavender #E6E6FA ShadesMix
LavenderBlush #FFF0F5 ShadesMix
LawnGreen #7CFC00 ShadesMix
LemonChiffon #FFFACD ShadesMix
LightBlue #ADD8E6 ShadesMix
LightCoral #F08080 ShadesMix
LightCyan #E0FFFF ShadesMix
LightGoldenRodYellow #FAFAD2 ShadesMix
LightGray #D3D3D3 ShadesMix
LightGrey #D3D3D3 ShadesMix
LightGreen #90EE90 ShadesMix
LightPink #FFB6C1 ShadesMix
LightSalmon #FFA07A ShadesMix
LightSeaGreen #20B2AA ShadesMix
LightSkyBlue #87CEFA ShadesMix
LightSlateGray #778899 ShadesMix
LightSlateGrey #778899 ShadesMix
LightSteelBlue #B0C4DE ShadesMix
LightYellow #FFFFE0 ShadesMix
Lime #00FF00 ShadesMix
LimeGreen #32CD32 ShadesMix
Linen #FAF0E6 ShadesMix
Magenta #FF00FF ShadesMix
Maroon #800000 ShadesMix
MediumAquaMarine #66CDAA ShadesMix
MediumBlue #0000CD ShadesMix
MediumOrchid #BA55D3 ShadesMix
MediumPurple #9370DB ShadesMix
MediumSeaGreen #3CB371 ShadesMix
MediumSlateBlue #7B68EE ShadesMix
MediumSpringGreen #00FA9A ShadesMix
MediumTurquoise #48D1CC ShadesMix
MediumVioletRed #C71585 ShadesMix
MidnightBlue #191970 ShadesMix
MintCream #F5FFFA ShadesMix
MistyRose #FFE4E1 ShadesMix
Moccasin #FFE4B5 ShadesMix
NavajoWhite #FFDEAD ShadesMix
Navy #000080 ShadesMix
OldLace #FDF5E6 ShadesMix
Olive #808000 ShadesMix
OliveDrab #6B8E23 ShadesMix
Orange #FFA500 ShadesMix
OrangeRed #FF4500 ShadesMix
Orchid #DA70D6 ShadesMix
PaleGoldenRod #EEE8AA ShadesMix
PaleGreen #98FB98 ShadesMix
PaleTurquoise #AFEEEE ShadesMix
PaleVioletRed #DB7093 ShadesMix
PapayaWhip #FFEFD5 ShadesMix
PeachPuff #FFDAB9 ShadesMix
Peru #CD853F ShadesMix
Pink #FFC0CB ShadesMix
Plum #DDA0DD ShadesMix
PowderBlue #B0E0E6 ShadesMix
Purple #800080 ShadesMix
RebeccaPurple #663399 ShadesMix
Red #FF0000 ShadesMix
RosyBrown #BC8F8F ShadesMix
RoyalBlue #4169E1 ShadesMix
SaddleBrown #8B4513 ShadesMix
Salmon #FA8072 ShadesMix
SandyBrown #F4A460 ShadesMix
SeaGreen #2E8B57 ShadesMix
SeaShell #FFF5EE ShadesMix
Sienna #A0522D ShadesMix
Silver #C0C0C0 ShadesMix
SkyBlue #87CEEB ShadesMix
SlateBlue #6A5ACD ShadesMix
SlateGray #708090 ShadesMix
SlateGrey #708090 ShadesMix
Snow #FFFAFA ShadesMix
SpringGreen #00FF7F ShadesMix
SteelBlue #4682B4 ShadesMix
Tan #D2B48C ShadesMix
Teal #008080 ShadesMix
Thistle #D8BFD8 ShadesMix
Tomato #FF6347 ShadesMix
Turquoise #40E0D0 ShadesMix
Violet #EE82EE ShadesMix
Wheat #F5DEB3 ShadesMix
White #FFFFFF ShadesMix
WhiteSmoke #F5F5F5 ShadesMix
Yellow #FFFF00 ShadesMix
YellowGreen #9ACD32 ShadesMix

Color Names Sorted by Color Groups

All modern browsers support the following 140 color names (click on a color name, or a hex value, to view the color as the background-color along with different text colors):

Pink Colors

Color NameHEXColorShadesMix
Pink #FFC0CB ShadesMix
LightPink #FFB6C1 ShadesMix
HotPink #FF69B4 ShadesMix
DeepPink #FF1493 ShadesMix
PaleVioletRed #DB7093 ShadesMix
MediumVioletRed #C71585 ShadesMix

Purple Colors

Color NameHEXColorShadesMix
Lavender #E6E6FA ShadesMix
Thistle #D8BFD8 ShadesMix
Plum #DDA0DD ShadesMix
Orchid #DA70D6 ShadesMix
Violet #EE82EE ShadesMix
Fuchsia #FF00FF ShadesMix
Magenta #FF00FF ShadesMix
MediumOrchid #BA55D3 ShadesMix
DarkOrchid #9932CC ShadesMix
DarkViolet #9400D3 ShadesMix
BlueViolet #8A2BE2 ShadesMix
DarkMagenta #8B008B ShadesMix
Purple #800080 ShadesMix
MediumPurple #9370DB ShadesMix
MediumSlateBlue #7B68EE ShadesMix
SlateBlue #6A5ACD ShadesMix
DarkSlateBlue #483D8B ShadesMix
RebeccaPurple #663399 ShadesMix
Indigo  #4B0082 ShadesMix

Red Colors

Color NameHEXColorShadesMix
LightSalmon #FFA07A ShadesMix
Salmon #FA8072 ShadesMix
DarkSalmon #E9967A ShadesMix
LightCoral #F08080 ShadesMix
IndianRed  #CD5C5C ShadesMix
Crimson #DC143C ShadesMix
Red #FF0000 ShadesMix
FireBrick #B22222 ShadesMix
DarkRed #8B0000 ShadesMix

Orange Colors

Color NameHEXColorShadesMix
Orange #FFA500 ShadesMix
DarkOrange #FF8C00 ShadesMix
Coral #FF7F50 ShadesMix
Tomato #FF6347 ShadesMix
OrangeRed #FF4500 ShadesMix

Yellow Colors

Color NameHEXColorShadesMix
Gold #FFD700 ShadesMix
Yellow #FFFF00 ShadesMix
LightYellow #FFFFE0 ShadesMix
LemonChiffon #FFFACD ShadesMix
LightGoldenRodYellow #FAFAD2 ShadesMix
PapayaWhip #FFEFD5 ShadesMix
Moccasin #FFE4B5 ShadesMix
PeachPuff #FFDAB9 ShadesMix
PaleGoldenRod #EEE8AA ShadesMix
Khaki #F0E68C ShadesMix
DarkKhaki #BDB76B ShadesMix

Green Colors

Color NameHEXColorShadesMix
GreenYellow #ADFF2F ShadesMix
Chartreuse #7FFF00 ShadesMix
LawnGreen #7CFC00 ShadesMix
Lime #00FF00 ShadesMix
LimeGreen #32CD32 ShadesMix
PaleGreen #98FB98 ShadesMix
LightGreen #90EE90 ShadesMix
MediumSpringGreen #00FA9A ShadesMix
SpringGreen #00FF7F ShadesMix
MediumSeaGreen #3CB371 ShadesMix
SeaGreen #2E8B57 ShadesMix
ForestGreen #228B22 ShadesMix
Green #008000 ShadesMix
DarkGreen #006400 ShadesMix
YellowGreen #9ACD32 ShadesMix
OliveDrab #6B8E23 ShadesMix
DarkOliveGreen #556B2F ShadesMix
MediumAquaMarine #66CDAA ShadesMix
DarkSeaGreen #8FBC8F ShadesMix
LightSeaGreen #20B2AA ShadesMix
DarkCyan #008B8B ShadesMix
Teal #008080 ShadesMix

Cyan Colors

Color NameHEXColorShadesMix
Aqua #00FFFF ShadesMix
Cyan #00FFFF ShadesMix
LightCyan #E0FFFF ShadesMix
PaleTurquoise #AFEEEE ShadesMix
Aquamarine #7FFFD4 ShadesMix
Turquoise #40E0D0 ShadesMix
MediumTurquoise #48D1CC ShadesMix
DarkTurquoise #00CED1 ShadesMix

Blue Colors

Color NameHEXColorShadesMix
CadetBlue #5F9EA0 ShadesMix
SteelBlue #4682B4 ShadesMix
LightSteelBlue #B0C4DE ShadesMix
LightBlue #ADD8E6 ShadesMix
PowderBlue #B0E0E6 ShadesMix
LightSkyBlue #87CEFA ShadesMix
SkyBlue #87CEEB ShadesMix
CornflowerBlue #6495ED ShadesMix
DeepSkyBlue #00BFFF ShadesMix
DodgerBlue #1E90FF ShadesMix
RoyalBlue #4169E1 ShadesMix
Blue #0000FF ShadesMix
MediumBlue #0000CD ShadesMix
DarkBlue #00008B ShadesMix
Navy #000080 ShadesMix
MidnightBlue #191970 ShadesMix

Brown Colors

Color NameHEXColorShadesMix
Cornsilk #FFF8DC ShadesMix
BlanchedAlmond #FFEBCD ShadesMix
Bisque #FFE4C4 ShadesMix
NavajoWhite #FFDEAD ShadesMix
Wheat #F5DEB3 ShadesMix
BurlyWood #DEB887 ShadesMix
Tan #D2B48C ShadesMix
RosyBrown #BC8F8F ShadesMix
SandyBrown #F4A460 ShadesMix
GoldenRod #DAA520 ShadesMix
DarkGoldenRod #B8860B ShadesMix
Peru #CD853F ShadesMix
Chocolate #D2691E ShadesMix
Olive #808000 ShadesMix
SaddleBrown #8B4513 ShadesMix
Sienna #A0522D ShadesMix
Brown #A52A2A ShadesMix
Maroon #800000 ShadesMix

White Colors

Color NameHEXColorShadesMix
White #FFFFFF ShadesMix
Snow #FFFAFA ShadesMix
HoneyDew #F0FFF0 ShadesMix
MintCream #F5FFFA ShadesMix
Azure #F0FFFF ShadesMix
AliceBlue #F0F8FF ShadesMix
GhostWhite #F8F8FF ShadesMix
WhiteSmoke #F5F5F5 ShadesMix
SeaShell #FFF5EE ShadesMix
Beige #F5F5DC ShadesMix
OldLace #FDF5E6 ShadesMix
FloralWhite #FFFAF0 ShadesMix
Ivory #FFFFF0 ShadesMix
AntiqueWhite #FAEBD7 ShadesMix
Linen #FAF0E6 ShadesMix
LavenderBlush #FFF0F5 ShadesMix
MistyRose #FFE4E1 ShadesMix

Grey Colors

Color NameHEXColorShadesMix
Gainsboro #DCDCDC ShadesMix
LightGray #D3D3D3 ShadesMix
Silver #C0C0C0 ShadesMix
DarkGray #A9A9A9 ShadesMix
DimGray #696969 ShadesMix
Gray #808080 ShadesMix
LightSlateGray #778899 ShadesMix
SlateGray #708090 ShadesMix
DarkSlateGray #2F4F4F ShadesMix
Black #000000 ShadesMix

Styling HTML with CSS

CSS stands for Cascading Style Sheets.
CSS describes how HTML elements are to be displayed on screen, paper, or in other media.
CSS saves a lot of work. It can control the layout of multiple web pages all at once.
CSS can be added to HTML elements in 3 ways:
  • Inline - by using the style attribute in HTML elements
  • Internal - by using a <style> element in the <head> section
  • External - by using an external CSS file
The most common way to add CSS, is to keep the styles in separate CSS files. However, here we will use inline and internal styling, because this is easier to demonstrate, and easier for you to try it yourself.

Inline CSS

An inline CSS is used to apply a unique style to a single HTML element.
An inline CSS uses the style attribute of an HTML element.
This example sets the text color of the <h1> element to blue:

Example

<h1 style="color:blue;">This is a Blue Heading</h1>    

Code:

<!DOCTYPE html>
<html>
<body>

<h1 style="color:blue;">This is a Blue Heading</h1>

</body>
</html>

Output: 

This is a Blue Heading


HTML Links:  

HTML Links - Syntax

In HTML, links are defined with the <a> tag:
<a href="url">link text</a>

<!DOCTYPE html>
<html>
<body>

<h2>HTML Links</h2>
<p>
<a href="https://www.facebook.com/html/">Click here</a>
</p>

</body>
</html>

Output:

HTML Links

Click here 







No comments:

Post a Comment

 

Advertisement

Your ads here

Advertisement

Your ads here

Advertisement

Ads here
 
Blogger Templates