1- BASIC:
1) All HTML DOCUMENTS must start with a document type declaration: !DOCTYPE html>.
2) The HTML document itself begins with html> and ends with /html>.
3) The visible part of the HTML document is between >body> and >/body>.
4) HTML HEADINGS are defined with the <h1> to <h6> tags.
5) <h1> defines the most important heading. <h6> defines the least important heading:
6) HTML headings are defined with the <h1> to <h6> tags.
7) HTML PARAGRAPHS are defined with the </h6></h1></h6></h1></h6></h1><p> tag
7) HTML LINKS are defined with the <a> tag. The link’s destination is specified in the href attribute.
8) HTML IMAGES are defined with the <img></img> tag. The source file (src), alternative text (alt), width, and height are provided as attributes.
9) HTML BUTTONS are defined with the tag
10) HTML LISTS are defined with the <ul> (unordered/bullet list) or the </ul><ol> (ordered/numbered list) tag, followed by <li> tags (list items).</li></ol></a></p>
2- HTML Elements
1) An HTML element usually consists of a start tag and an end tag, with the content inserted in between:
tagname>Content goes here…/tagname>
2) Nested HTML Elements: HTML elements can be nested (elements can contain elements).
3) Do Not Forget the End Tag
4) HTML elements with no content are called empty elements. <br></br>
5) HTML Is Not Case Sensitive: HTML tags are not case sensitive: <p> means the same as </p><p>.</p>
3- HTML Attributes
1) All HTML elements can have attributes
2) ATTRIBUTES provide additional information about an element
3) Attributes are always specified in the start tag
4) Attributes usually come in name/value pairs like: name=”value”
5) HTML LINKS are defined with the <a> tag. The link address is specified in the href attribute.
6) HTML IMAGES are defined with the <img></img> tag. The filename of the image source is specified in the src attribute
7) HTML images also have WIDHT AND HEIGTH ATTRIBUTES, which specifies the width and height of the image. The width and height are specified in pixels by default; so width=”500” means 500 pixels wide.
8) The ALT attribute specifies an alternative text to be used, if an image cannot be displayed.
9) The value of the alt attribute can be read by screen readers. This way, someone “listening” to the webpage, e.g. a vision impaired person, can “hear” the element.
10) The STYLE ATTRIBUTE is used to specify the styling of an element, like color, font, size etc.
11) The LANGUAJE of the document can be declared in the tag. The language is declared with the lang attribute. Declaring a language is important for accessibility applications (screen readers) and search engines. The first two letters specify the language (en). If there is a dialect, add two more letters (US).
12) 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.</a>
13) We Suggest: Use Lowercase Attributes. The HTML5 standard does not require lowercase attribute names.
The title attribute can be written with uppercase or lowercase like title or TITLE. W3C recommends lowercase in HTML, and demands lowercase for stricter document types like XHTML.
14) We Suggest: Quote Attribute Values: The HTML5 standard does not require quotes around attribute values. For intance the href attribute can be written without quotes.
15) 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.
_______________
Chapter Summary
- All HTML elements can have attributes
- The title attribute provides additional “tool-tip” information
- The href attribute provides address information for links
- The width and height attributes provide size information for images
- The alt attribute provides text for screen readers
At W3Schools we always use lowercase attribute names
At W3Schools we always quote attribute values</p></a>
4- HTML Headings
1) HEADINGS are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important heading.
2) Bigger Headings
Each HTML heading has a default size. However, you can specify the size for any heading with the style attribute, using the CSS font-size property: h1 style = "font-size: 60px;
3) The <hr></hr> tag defines a thematic break in an HTML page, and is most often displayed as a horizontal rule.
The <hr></hr> element is used to separate content (or define a change) in an HTML page</h6></h1>
</h6></h1>
5- BASIC STRUCTURE:
> !DOCTYPE html>
html>
>head>
>/head>
>body>
h1 -This is a Heading- /h1
p -This is a paragraph.- /p
>/body>
>/html>1) The !DOCTYPE html> declaration defines this document to be HTML5
2) The html> element is the root element of an HTML page
3) The head> element contains meta information about the document
4) The title> element specifies a title for the document
5) The body> element contains the visible page content
6) The h1> element defines a large heading
7) The p> element defines a paragraph
6- HTML Paragraphs:
> p>This is a paragraph. /p>
p>This is another paragraph. /p>
> pre> Element
Tag Description
<p> Defines a paragraph
<br></br> Inserts a single line break
</p>
<pre> Defines pre-formatted text</pre>
7- HTML Tags:
1) HTML tags are element names surrounded by angle brackets:
tagname>content goes here… /tagname>
2) HTML tags normally come in pairs like p> and /p>
3) The first tag in a pair is the start tag, the second tag is the end tag
4) The end tag is written like the start tag, but with a forward slash inserted before the tag name
8- The !DOCTYPE> Declaration:
9- HTML History:
Year Version 1989 Tim Berners-Lee invented www 1991 Tim Berners-Lee invented HTML 1993 Dave Raggett drafted HTML+ 1995 HTML Working Group defined HTML 2.0 1997 W3C Recommendation: HTML 3.2 1999 W3C Recommendation: HTML 4.01 2000 W3C Recommendation: XHTML 1.0 2008 WHATWG HTML5 First Public Draft 2012 WHATWG HTML5 Living Standard 2014 W3C Recommendation: HTML5 2016 W3C Candidate Recommendation: HTML 5.1 2017 W3C Recommendation: HTML5.1 2nd Edition
10- HTML Styles:
11- HTML Formatting Elements:
<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 \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Tag Description <b> Defines bold text <em> Defines emphasized text <i> Defines italic text <small> Defines smaller text <strong> Defines important text <sub> Defines subscripted text <sup> Defines superscripted text <ins> Defines inserted text <del> Defines deleted text mark> Defines marked/highlighted text </del></ins> Defines inserted text</sup></sub></strong></small></i></em></b></sup></sub></ins></del></small></em></i></strong></b>
12- HTML Quotation and Citation Elements:
- The HTML <address> element defines contact information (author/owner) of a document or an article. >address> Written by John Doe.(br> Visit us at:(br> >/address>
<address> Defines contact information for the author/owner of a document
Defines bi-directional override.
<blockquote> Defines a section that is quoted from another source
<cite> Defines the title of a work
Defines a short inline quotation</cite></blockquote></address>
</abbr></cite></address></abbr></blockquote>
13- HTML Comments:
14- HTML Colors:
2) RGBA Value
rgba(red, green, blue, alpha)
15- HTML Styles - CSS:
a) Styling HTML with 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.
> h1 style=”color:blue;”>This is a Blue Heading>/h1>
____________________
c) INTERNAL CSS: is used to define a style for a single HTML page.
An internal CSS is defined in the section of an HTML page, within a element:
>!DOCTYPE html>
>html>
>head>
>style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
>/style>
>/head>
>body>
>h1>This is a heading(/h1>
>p>This is a paragraph.(/p>
>/body>
>/html>
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
d) EXTERNAL CSS: An external style sheet is used to define the style for many HTML pages.>!DOCTYPE html>
>html>
>head>
>link rel="stylesheet" href="styles.css">
>/head>
>body>
>h1>This is a heading>/h1>
>p>This is a paragraph.>/p>
>/body>
>/html>
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
e) CSS FONTS: The CSS color property defines the text color to be used.>!DOCTYPE html>
>html>
>head>
>style>
h1 {
color: blue;
font-family: verdana;
font-size: 300%;
}
p {
color: red;
font-family: courier;
font-size: 160%;
}
>/style>
>/head>
>body>
>h1>This is a heading
>p>This is a paragraph.
>/body>
>/html>
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
f) CSS BORDER: property defines a border around an HTML element:p {
border: 1px solid powderblue;
}
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
g) CSS PADDING: The CSS padding property defines a padding (space) between the text and the border:p {
border: 1px solid powderblue;
padding: 30px;
}
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
h) CSS MARGIN: The CSS margin property defines a margin (space) outside the border:p {
border: 1px solid powderblue;
margin: 50px;
}
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
i) The ID ATTRIBUTE: To define a specific style for one special element, add an id attribute to the element:> p id=”p01”>I am different(/p>
#p01 {
color: blue;
}
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
j) The CLASS ATTRIBUTE: To define a style for special types of elements, add a class attribute to the element:> p class=”error”>I am different(/p>
then define a style for the elements with the specific class:
p.error {
color: red;
}
____________________
k) EXTERNAL REFERENCES: External style sheets can be referenced with a full URL or with a path relative to the current web page.
Example
(link rel=”stylesheet” href=”https://www.w3schools.com/html/styles.css”>
____________________
Chapter Summary
- Use the HTML style attribute for inline styling
- Use the HTML element to define internal CSS
- Use the HTML <link></link> element to refer to an external CSS file
- Use the HTML <head> element to store <style> and <link></link> elements
- Use the CSS color property for text colors
- Use the CSS font-family property for text fonts
- Use the CSS font-size property for text sizes
- Use the CSS border property for borders
- Use the CSS padding property for space inside the border
- Use the CSS margin property for space outside the border</style>
16- HTML Links:
When you move the mouse over a link, the mouse arrow will turn into a little hand.
Note: A link does not have to be text. It can be an image or any other HTML element.
The target attribute can have one of the following values:
_blank - Opens the linked document in a new window or tab
_self - Opens the linked document in the same window/tab as it was clicked (this is default)
_parent - Opens the linked document in the parent frame
_top - Opens the linked document in the full body of the window
framename - Opens the linked document in a named frame
Example
>a href=”https://www.w3schools.com/” target=”_blank”>Visit W3Schools!>/a>
Example
>a href=”default.asp”>
(img src=”smiley.gif” alt=”HTML tutorial” style=”width:42px;height:42px;border:0;”>
>/a>
Example
>button onclick=”document.location = ‘default.asp’“>HTML Tutorial>/button>
Example
>a href=”https://www.w3schools.com/html/” title=”Go to W3Schools HTML section”>Visit our HTML Tutorial>/a>
Example
>a href=”https://www.w3schools.com/html/default.asp”>HTML tutorial>/a>
___________________
Chapter Summary
- Use the </a><a> element to define a link
- Use the href attribute to define the link address
- Use the target attribute to define where to open the linked document
- Use the <img></img> element (inside </a><a>) to use an image as a link
</a>
17- HTML Link Colors:
- You can change the default colors, by using CSS:
>style>
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}
>/style>
18- Link Buttons:
A LINK can also be styled AS A BUTTON, by using CSS:
>style>
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 15px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}a:hover, a:active {
background-color: red;
}
>/style>
19- HTML Link Bookmarks:
First, create a bookmark with the id attribute:
>h2 id=”C4”>Chapter 4>/h2>
>a href=”#C4”>Jump to Chapter 4>/a>
You can also add a link to a bookmark on another page:
>a href=”html_demo.html#C4”>Jump to Chapter 4>/a>
____________________
Chapter Summary
- Use the id attribute (id=”value”) to define bookmarks in a page
- Use the href attribute (href=”#value”) to link to the bookmark
20- HTML Images:
> img src=”pic_trulli.jpg” alt=”Italian Trulli”>
The <img></img> tag is empty, it contains attributes only, and does not have a closing tag.
The src attribute specifies the URL (web address) of the image:
> img src=”img_girl.jpg” alt=”Girl in a jacket”>
The value of the alt attribute should describe the image:
Example: (img src=”img_chania.jpg” alt=”Flowers in Chania”>
Example: (img style=”width:500px;height:600px;”>
However, we suggest using the style attribute. It prevents styles sheets from changing the size of images:
>!DOCTYPE html>
>html>
>head>
>style>
img {
width: 100%;
}
>/style>
>/head>
>body>
>img src="html5.gif" alt="HTML5 Icon" width="128"
height="128">
>img src="html5.gif" alt="HTML5 Icon"
style="width:128px;height:128px;">
>/body>
>/html>However, it is common to store images in a sub-folder. You must then include the folder name in the src attribute:
Example: >img src=”/images/html5.gif” alt=”HTML5 Icon” style=”width:128px;height:128px;”>
Actually, you can access images from any web address in the world:
Example: >img src=”https://www.w3schools.com/images/w3schools_green.jpg” alt=”W3Schools.com”>
Example: >img src=”programming.gif” alt=”Computer Man” style=”width:48px;height:48px;”>
Example:
>a href=”default.asp”>
>img src=”smiley.gif” alt=”HTML tutorial” style=”width:42px;height:42px;border:0;”>
>/a>
Example
>p>(img src=”smiley.gif” alt=”Smiley face” style=”float:right;width:42px;height:42px;”>
The image will float to the right of the text.>/p>
> p>(img src=”smiley.gif” alt=”Smiley face” style=”float:left;width:42px;height:42px;”>
The image will float to the left of the text.
____________________
Chapter Summary
- Use the HTML <img></img> element to define an image
- Use the HTML src attribute to define the URL of the image
- Use the HTML alt attribute to define an alternate text for an image, if it cannot be displayed
- Use the HTML width and height attributes to define the size of the image
- Use the CSS width and height properties to define the size of the image (alternatively)
- Use the CSS float property to let the image float
21- HTML Image Maps:
> map name=”workmap”>
area shape=”rect” coords=”34,44,270,350” alt=”Computer” href=”computer.htm”>
area shape=”rect” coords=”290,172,333,250” alt=”Phone” href=”phone.htm”>
area shape=”circle” coords=”337,300,44” alt=”Coffee” href=”coffee.htm”>
/map>
> img src=”workplace.jpg” alt=”Workplace” usemap=”#workmap”>
The usemap value starts with a hash tag # followed by the name of the image map, and is used to create a relationship between the image and the image map.
> map name=”workmap”>
The name attribute must have the same value as the usemap attribute.
Add a click event on the element to execute a JavaScript function:
Example
You can use the onclick attribute to execute a JavaScript function when the area is clicked
> area shape=”circle” coords=”337,300,44” onclick=”myFunction()”>
____________________
Chapter Summary
- Use the HTML element to define an image-map
- Use the HTML element to define the clickable areas in the image-map
- Use the HTML <img></img>’s element usemap attribute to point to an image-map.
22- HTML Background Images:
Example
Add a background image on a HTML element:
(div style=”background-image: url(‘img_girl.jpg’);”>
Example
Add a background image on a HTML page:
>style>
body {
background-image: url('img_girl.jpg');
}
>/style>The background-image property will try to fill the div element with images until it has reach the end.
Example
>style>
body {
background-image: url('example_img_girl.jpg');
}
>/style>>style>
body {
background-image: url('img_girl.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
>/style>Example
>style>
body {
background-image: url('img_girl.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
>/style>23- HTML Picture Element:
Note: Always specify an <img></img> element as the last child element of the element. The <img></img> element is used by browsers that do not support the element, or if none of the tags matched.
24- HTML Tables:
Each table row is defined with the tag. A table header is defined with the tag. By default, table headings are bold and centered. A table data/cell is defined with the tag.
- Example
>table style="width:100%">
>tr>
Firstname
Lastname>/th>
>th>Age>/th>
>/tr>
>tr>
>td>Jill>/td>
>td>Smith>/td>
>td>50>/td>
>/tr>
>tr>
>td>Eve>/td>
>td>Jackson>/td>
>td>94>/td>
>/tr>
>/table>Example
table, th, td {
border: 1px solid black;
}
Example
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}If you do not specify a padding, the table cells will be displayed without padding.
Example:
th, td {
padding: 15px;
}
Example
th {
text-align: left;
}
Example
table {
border-spacing: 5px;
}
Note: If the table has collapsed borders, border-spacing has no effect.
Example
>table style="width:100%">
>tr>
>th>Name>/th>
>th colspan="2">Telephone>/th>
>/tr>
>tr>
>td>Bill Gates>/td>
>td>55577854>/td>
>td>55577855>/td>
>/tr>
>/table>Example
>table style="width:100%">
>tr>
>th>Name:>/th>
>td>Bill Gates>/td>
>/tr>
>tr>
>th rowspan="2">Telephone:>/th>
>td>55577854>/td>
>/tr>
>tr>
>td>55577855>/td>
>/tr>
>/table>Example
>table style="width:100%">
>caption>Monthly savings>/caption>
>tr>
>th>Month>/th>
>th>Savings>/th>
>/tr>
>tr>
>td>January>/td>
>td>$100>/td>
>/tr>
>tr>
>td>February>/td>
>td>$50>/td>
>/tr>
>/table>Example
>table id="t01">
>tr>
>th>Firstname>/th>
>th>Lastname>/th>
>th>Age>/th>
>/tr>
>tr>
>td>Eve>/td>
>td>Jackson>/td>
>td>94>/td>
>/tr>
>/table>Now you can define a special style for this table:
table#t01 {
width: 100%;
background-color: #f1f1c1;
}And add more styles:
table#t01 tr:nth-child(even) {
background-color: #eee;
}
table#t01 tr:nth-child(odd) {
background-color: #fff;
}
table#t01 th {
color: white;
background-color: black;
}
____________________
Chapter Summary
- Use the HTML element to define a table
- Use the HTML element to define a table row
- Use the HTML element to define a table data
- Use the HTML element to define a table heading
- Use the HTML element to define a table caption
- Use the CSS border property to define a border
- Use the CSS border-collapse property to collapse cell borders
- Use the CSS padding property to add padding to cells
- Use the CSS text-align property to align cell text
- Use the CSS border-spacing property to set the spacing between cells
- Use the colspan attribute to make a cell span many columns
- Use the rowspan attribute to make a cell span many rows
- Use the id attribute to uniquely define one table
-
____________________ - INLINE ELEMENTS: An inline element does not start on a new line and only takes up as much width as necessary. This is an inline element inside a paragraph. Example (span>Hello World(/span> ``` Inline elements in HTML: ```
`````` ``` ``` ____________________ - the
Element: is often used as a container for other HTML elements. Theelement has no required attributes, but style, class and id are common. When used together with CSS, theelement can be used to style blocks of content: Example >div style="background-color:black;color:white;padding:20px;"> >h2>London(/h2> >p>London is the capital city of England. It is the most populous city in the United Kingdom.>/p> >/div> ____________________ - The Element: is often used as a container for some text. The element has no required attributes, but style, class and id are common. When used together with CSS, the element can be used to style parts of the text: Example >h1>My >span style="color:red">Important>/span> Heading>/h1> ____________________ - HTML GROUPING TAGS Tag DescriptionDefines a section in a document (block-level) Defines a section in a document (inline)
, can have the same class name and thereby share the same style: Example >h2 class="city">ParisÇ8/h2> >p class="city">Paris is the capital of France>/p>
London is the capital of England.
____________________ - BOOKMARKS WITH ID AND LINKS: HTML bookmarks are used to allow readers to jump to specific parts of a Web page. Bookmarks can be useful if your webpage is very long. To make a bookmark, you must first create the bookmark, and then add a link to it. When the link is clicked, the page will scroll to the location with the bookmark. Example First, create a bookmark with the id attribute: (h2 id="C4">Chapter 4(/h2> Then, add a link to the bookmark ("Jump to Chapter 4"), from within the same page: (a href="#C4">Jump to Chapter 4(/a> Or, add a link to the bookmark ("Jump to Chapter 4"), from another page: Example (a href="html_demo.html#C4">Jump to Chapter 4(/a>