Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

HTML Tutorial

HTML(5) Tutorial

You can create your own Web site With HTML .

This tutorial teach you the lot of HTML chapter.

Very Easy to learn HTML - You will enjoy it.
html-tutorial

Examples in Every Chapter


HTML examples With our online HTML editor try it , you can edit the HTML, and click submit  button to view the result.

 

 HTML Example:

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

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

</body>
</html>

Try it Yourself

HTML Introduction

HTML Introduction

What is HTML?


  • HTML is a markup language for describing web documents .
  • HTML stands for Hyper Text Markup Language.
  • A markup language is a set of markup tags.
  • HTML documents are described by HTML tags.
  • Each HTML tag describes different document content.

HTML A Small Example :

HTML Small Document:

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

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>

Try it Yourself


Example Explained


  • The DOCTYPE declaration defines the document type to be HTML.
  • The text between <html> and </html> tag describes an HTML document.
  • The text between <head> and </head> tag  provides information about the document.
  • The text between <title> and </title> tag  provides a title for the document.
  • The text between <body> and </body> tag  describes the visible page content.
  • The text between <h1> and </h1> tag  describes a heading.
  • The text between <p> and </p> tag  describes a paragraph.
  • Using this description, a web browser can display a document with a heading and a paragraph.


HTML Tags


HTML tags are keywords (tag names) surrounded by angle brackets:

<tagname>content</tagname>

  • HTML tags normally come in pairs like <p> and </p> tag.
  • 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, but with a slash before the tag name.
  • The start tag is often called the opening tag. The end tag is often called the closing tag.

Web Browsers


The purpose of a web browser  is to read HTML documents and display them (Chrome, IE, Firefox, Safari).

The browser does not display the HTML tags, but uses them to determine how to display the document:


HTML Page Structure


Below is a visualization of an HTML page structure:


The <!DOCTYPE> Declaration


  • The <!DOCTYPE> declaration helps the browser to display a web page correctly.
  • There are different document types on the web.
  • To display a document correctly, the browser must know both type and version.
  • The doctype declaration is not case sensitive. All cases are acceptable:
<!DOCTYPE html>

<!DOCTYPE HTML>

<!doctype html>

<!Doctype Html>


Common Declarations


HTML5
<!DOCTYPE html>


HTML 4.01
<!DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">


XHTML 1.0
<!DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

HTML Editors

HTML Editors

Write HTML Using Notepad or TextEdit

HTML can be edited by using professional HTML editors like:
  • Microsoft WebMatrix 
  • Sublime Text 
However, for learning HTML we recommend a text editor like Notepad (PC) or TextEdit (Mac) or any other editors.
We believe using a simple text editor is a good way to learn HTML.
Follow the steps below to create your first web page with Notepad.

Step 1: Open Notepad

To open Notepad in Windows 7 or earlier: Click Start (bottom left on your screen). Click All Programs. Click Accessories. Click Notepad. To open Notepad in Windows 8 or later: Open the Start Screen (the window symbol at the bottom left on your screen). Type Notepad.

Step 2: Write Some HTML

Write or copy some HTML into Notepad.
<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>

Step 3: Save the HTML Page

  • Save the file on your computer. 
  • Select File > Save as in the Notepad menu. 
  • Name the file "index.html" or any other name ending with html or htm. 
  • UTF-8 is the preferred encoding for HTML files. 
  • ANSI encoding covers US and Western European characters only. 
  • You can use either .htm or .html as file extension. There is no difference, it is up to you. 

Step 4: View HTML Page in Your Browser

Open the saved HTML file in your browser.  To open a file in a browser, double click on the file, or right-click, and choose open with. The result will look much like this:

HTML Basic

HTML Basic Examples

In this Topic Explained HTML Tags examples.
Don't worry if these examples use tags you have not learned.

HTML Documents


All HTML documents must start with a 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>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>

Try it Yourself


HTML Headings


HTML headings are defined with the <h1> to <h6> tags:

Example :

<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>

Try it Yourself


HTML Paragraphs


HTML paragraphs are defined with the <p> tag:

Example :

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

Try it Yourself


HTML Links


HTML links are defined with the <a> tag:

Example :

<a href="http://www.learncodeing.blogspot.com">This is a link </a>

Try it Yourself


The link's destination is specified in the href attribute.

Attributes are used to provide additional information about HTML elements.


HTML Images


HTML images are defined with the <img> tag.

The source file (src), alternative text (alt), and size (width and height) are provided as attributes:

Example :

<imgs  src="http://imgcluster.com/wp-content/uploads/2015/08/Wallpapers-tulips-in-the-snow-steven-milner-388x220.jpg" alt="learncodeing.blogspot.com" width="200" height="200">

Try it Yourself


HTML Elements

HTML Elements

HTML Elements


HTML documents are made up by HTML elements.

HTML elements are written with a start tag, with an end tag, with the content in between:

        <tagname>content</tagname>

The HTML element is everything from the start tag to the end tag:

       <p>My first HTML paragraph.</p>    

Some HTML elements do not have an end tag.
Start tagElement contentEnd tag
<h1>My First Heading</h1>
<p>My first paragraph.</h1>
<br/>        -----    --

Nested HTML Elements


HTML elements can be nested (elements can contain elements).

All HTML documents consist of nested HTML elements.

This example contains 4 HTML elements:

Example:

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>

Try it Yourself

HTML Example Explained


The <html> element defines the whole document.

It has a start tag <html> and an end tag </html>.

The element content is another HTML element (the <body> element).

<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>


The <body> element defines the document body.

It has a start tag <body> and an end tag </body>.

The element content is two other HTML elements (<h1> and <p>).

<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>


The <h1> element defines a heading.

It has a start tag <h1> and an end tag </h1>.

The element content is: My First Heading.
<h1>My First Heading</h1>


The <p> element defines a paragraph.

It has a start tag <p> and an end tag </p>.

The element content is: My first paragraph.
<p>My first paragraph.</p>


Don't Forget the End Tag
Some HTML elements will display correctly, even if you forget the end tag:

Example:

<html>
<body>

<p>This is a paragraph
<p>This is a paragraph

</body>
</html>

Try it Yourself


The example above works in all browsers, because the closing tag is considered optional.

Never rely on this. It might produce unexpected results and/or errors if you forget the end tag.

Empty HTML Elements

  •  HTML elements with no content are called empty elements.
  • <br> is an empty element without a closing tag (the <br> tag defines a line break).
  • Empty elements can be "closed" in the opening tag like this: <br />.
  • HTML5 does not require empty elements to be closed. But if you want stricter validation, or you need to make your document readable by XML parsers, you should close all HTML elements.

HTML Tip: Use Lowercase Tags


HTML tags are not case sensitive: <P> means the same as <p>.

The HTML5 standard does not require lowercase tags, but W3C recommends lowercase in HTML4, and demands lowercase for stricter document types like XHTML.
HTML Attributes

HTML Attributes

HTML Attributes


  • Attributes provide additional information about HTML elements.
  • HTML elements can have attributes
  • Attributes provide additional information about an element
  • Attributes are always specified in the start tag
  • Attributes come in name/value pairs like: name="value"
Below is an alphabetical list of some attributes often used in HTML:
Attribute Description
alt pecifies an alternative text for an image
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)
value Specifies the value (text content) for an input element.

The lang Attribute


  • The document language can be declared in the <html> tag.
  • The language is declared in the lang attribute.
  • The first two letters specify the language (en). If there is a dialect, use two more letters (US).
  • Declaring a language is important for accessibility applications (screen readers) and search engines:

<!DOCTYPE html>
<html lang="en-US">
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>

The Title Attribute


HTML paragraphs are defined with the <p> tag.

In this example, the <p> element has a Title Attribute.
When you move the mouse over the element, the title will be displayed as a tooltip.
The value of the attribute is "About Learncodeing":

Example:

<p title="About Learncodeing">
Learincodeing is a web developer's site.
It provides tutorials and references covering
many aspects of web programming,
including HTML, CSS, JavaScript, XML, SQL, PHP and etc.
</p>

Try it Yourself

The Href Attribute


  • HTML links are defined with the <a> tag.
  • You will learn more about links and the <a> tag later in this tutorial.
The link address is specified in the href attribute:

Example:

<a href="http://www.learincoeing.blogspot.com">This is a link</a>

Try it Yourself

The Size Attributes


HTML images are defined with the <img> tag.
The image size is specified in pixels: width="200" means 200screen pixels wide.


The filename of the source (src), and the size of the image (width and height) are all provided as attributes:

Example:

<img src="http://imgcluster.com/wp-content/uploads/2015/08/Wallpapers-tulips-in-the-snow-steven-milner-388x220.jpg" width="200" height="200">

Try it Yourself

The Alt Attribute


The alt attribute specifies an alternative text to be used, when an HTML element cannot be displayed.

The value of the attribute can be read by "screen readers". This way, someone "listening" to the webpage, i.e. a blind person, can "hear" the element.

Example:

<img src="http://imgcluster.com/wp-content/uploads/2015/08/Wallpapers-tulips-in-the-snow-steven-milner-388x220.jpg" alt="Learncodeing.blogspot.com" width="200" height="200">

Try it Yourself


We Suggest: Always Use Lowercase Attributes


The HTML5 standard does not require lower case attribute names.

The title attribute can be written with upper or lower case like Title and/or TITLE.

W3C recommends lowercase in HTML4, and demands lowercase for stricter document types like XHTML.
Lower case is the most common. Lower case is easier to type.

We Suggest: Always Quote Attribute Values


The HTML5 standard does not require quotes around attribute values.

The href attribute, demonstrated above, can be written as:

Example:

<a href=http://www.learincodeing.blogspot.com>

Try it Yourself


W3C recommends quotes in HTML4, and demands quotes for stricter document types like XHTML.
Using quotes are the most common. Omitting quotes can produce errors.
Sometimes it is necessary to use quotes. This will not display correctly, because it contains a space:

Example:

<p title=About Learncodeing>

Try it Yourself


Single or Double Quotes?


Double style quotes are the most common in HTML, but single style can also be used.

In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes:

Example:

<p title='John "ShotGun" Nelson'>

Or vice versa:

Example:

<p title="John 'ShotGun' Nelson">


Summary of Chapter :

  •  All HTML elements can have attributes
  • The HTML title attribute provides additional "tool-tip" information
  • The HTML href attribute provides address information for links
  • The HTML width and height attributes provide size information for images
  • The HTML alt attribute provides text for screen readers
  • At Learincodeing we always use lowercase HTML attribute names
  • At Learincodeing we always quote attributes with double quotes
HTML Headings

HTML Headings

HTML Headings

Headings are important in HTML documents.
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 a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>

Try it Yourself

Headings Are Important

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.
Users skim your pages by its headings. It is important to use headings to show the document structure.
h1 headings should be main headings, followed by h2 headings, then the less important h3, and so on.

HTML Horizontal Rules

The <hr> tag creates a horizontal line in an HTML page.
The hr element can be used to separate content:

Example:

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

Try it Yourself

The HTML <head> Element

The HTML <head> element has nothing to do with HTML headings.
The HTML <head> element contains meta data. Meta data are not displayed.
The HTML <head> element is placed between the <html> tag and the <body> tag:

Example:

<!DOCTYPE html>
<html>

<head>
  <title>My First HTML</title>
  <meta charset="UTF-8">
</head>

<body>
.
.

Try it Yourself


The HTML <title> Element

The HTML <title> element is meta data. It defines the HTML document's title.
The title will not be displayed in the document, but might be displayed in the browser tab.

The HTML <meta> Element

The HTML <meta> element is also meta data.
It can be used to define the character set, and other information about the HTML document.

More Meta Elements

In the chapter about HTML styles you discover more meta elements:

The HTML <style> element is used to define internal CSS style sheets.

The HTML <link> element is used to define external CSS style sheets.

HTML Paragraphs

HTML Paragraphs

HTML Paragraphs

HTML documents are divided into paragraphs.
The HTML <p> element defines a paragraph.

Example:

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

Try it Yourself


HTML Display

You cannot be sure how HTML will be displayed.
Large or small screens, and resized windows will create different results.
With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code.
The browser will remove extra spaces and extra lines when the page is displayed.
Any number of spaces, and any number of new lines, count as only one space.

Example:

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

Try it Yourself


Don't Forget the End Tag

The example above will work in most browsers, but do not rely on it.
Forgetting the end tag can produce unexpected results or errors.
Most browsers will display HTML correctly even if you forget the end tag:

  Example:

<p>This is a paragraph
<p>This is another paragraph

Try it Yourself


HTML Line Breaks

The HTML <br> element defines a line break.
The <br> element is an empty HTML element. It has no end tag.
Use <br> if you want a line break (a new line) without starting a new paragraph:

Example:

<p>This is<br>a para<br>graph with line breaks</p>

Try it Yourself

The Poem Problem

Example:

<p>This poem will display as one line:</p>
<p>
  My Bonnie lies over the ocean.

  My Bonnie lies over the sea.

  My Bonnie lies over the ocean.

  Oh, bring back my Bonnie to me.
</p>

Try it Yourself

The HTML <pre> Element

The HTML <pre> element defines preformatted text.
The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks:

 Example:

<pre>
  My Bonnie lies over the ocean.

  My Bonnie lies over the sea.

  My Bonnie lies over the ocean.

  Oh, bring back my Bonnie to me.
</pre>

Try it Yourself