Showing posts with label html. Show all posts

The most common HTML lists are ordered and unordered lists:

An ordered list:

    1. The first list item
    2. The second list item
    3. The third list item


An unordered list:


HTML Unordered Lists

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
You can add any style as
<ul style="list-style-type:disc">
<ul style="list-style-type:circle">
<ul style="list-style-type:square">

HTML Ordered Lists

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.

The list items are marked with numbers.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>

Other types are
<ol type="A">
<ol type="a">
<ol type="I">
<ol type="i">

HTML Definition Lists

A definition list is a list of items, with a description of each item.

The <dl> tag defines a definition list.

The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item in the list):

<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>

Seen as


Nested List

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
    <li>Black tea</li>
    <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ul>


« Previous Chapter                                                                                                                                          Next Chapter »


Tables are defined with the <table> tag.

A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). td stands for "table data," and holds the content of a data cell. A <td> tag can contain text, links, images, lists, forms, other tables, etc.

Table Example

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

How the HTML code above looks in a browser:

row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2

HTML Tables and the Border Attribute

If you do not specify a border attribute, the table will be displayed without borders. Sometimes this can be useful, but most of the time, we want the borders to show.

To display a table with borders, specify the border attribute:

<table border="1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>

HTML Table Headers


Header information in a table are defined with the <th> tag.

All major browsers display the text in the <th> element as bold and centered.

<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

How the HTML code above looks in your browser:

Header 1 Header 2
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2

« Previous Chapter                                                                                                                                          Next Chapter »


HTML Images :: futureX
In HTML, images are defined with the <img> tag. 

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.

Syntax for defining an image:

<img src="url" alt="some_text">

The URL points to the location where the image is stored. An image named "abc.gif", located in the "images" directory on "www.example.com" has the URL: http://www.example.com/images/abc.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.



HTML Images - The Alt Attribute


The required alt attribute specifies an alternate text for an image, if the image cannot be displayed.

The value of the alt attribute is an author-defined text:

<img src="facebook.gif" alt="facebook logo">

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


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.

The attribute values are specified in pixels by default:

<img src="pulpit.jpg" alt="Pulpit rock" width="304" height="228">

Tip: It is a good practice to specify both the height and width attributes for an image. If these attributes are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image. The effect will be that the page layout will change during loading (while the images load).


Note: When a web page is loaded, it is the browser, at that moment, that actually gets the image from a web server and inserts it into the page. Therefore, make sure that the images actually stay in the same spot in relation to the web page, otherwise your visitors will get a broken link icon. The broken link icon is shown if the browser cannot find the image.


How to use an image as a link.


<p>Create a link of an image:
<a href="default.asp">
<img src="example.gif" alt="HTML tutorial" width="32" height="32"></a></p>



How to let an image float to the left or right of a paragraph.


<p>
<img src="smiley.gif" alt="Smiley face" style="float:left" width="32" height="32"> A paragraph with an image. The image will float to the left of this text.
</p>




« Previous Chapter                                                                                                                                          Next Chapter »

HTML styles :: futureX

CSS (Cascading Style Sheets) is used to style HTML elements.

CSS was introduced together with HTML 4, to provide a better way to style HTML elements.

CSS can be added to HTML in the following ways:

Inline - using the style attribute in HTML elements
Internal - using the <style> element in the <head> section
External - using an external CSS file

The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files.


Inline Styles


An inline style can be used if a unique style is to be applied to one single occurrence of an element.

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:

<p style="color:blue;margin-left:20px;">This is a paragraph.</p>



Internal Style Sheet


An internal style sheet can be used if one single document has a unique style. Internal styles are defined in the <head> section of an HTML page, by using the <style> tag, like this:

<head>
<style type="text/css">
body {background-color:yellow;}
p {color:blue;}
</style>
</head>


External Style Sheet


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><link rel="stylesheet" type="text/css" href="mystyle.css"></head>


CSS EXAMPLE :

<!DOCTYPE html>
<html>

<body style="background-color:gray;">
<h2 style="background-color:red;">This is a heading</h2>
<p style="background-color:green;">This is a line.</p>
</body>

</html>


<html>

<body>
<h1 style="font-family:verdana;">A heading</h1>
<p style="font-family:arial;color:red;font-size:20px;">A paragraph.</p>
</body>

</html>


<html>

<body>
<h1 style="text-align:center;">Center-aligned heading</h1>
<p>This is a paragraph.</p>
</body>

</html>
css example :: futureX



« Previous Chapter                                                                                                                                          Next Chapter »



HTML Head :: futureX

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


The HTML <title> Element

The <title> tag defines the title of the document.

The <title> element is required in all HTML/XHTML documents.

The <title> element:

defines a title in the browser toolbar
provides a title for the page when it is added to favorites
displays a title for the page in search-engine results


<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>

<body>
The content of the document......
</body>
</html>


The HTML <base> Element

The <base> tag specifies the base URL/target for all relative URLs in a page:

<head>
<base href="http://www.example.com/images/" target="_blank">
</head>


The HTML <link> Element

The <link> tag defines the relationship between a document and an external resource.

The <link> tag is most used to link to style sheets:

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>


The HTML <style> Element

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>


The HTML <meta> Element

Metadata is data (information) about data.

The <meta> tag provides metadata about the HTML document. Metadata will not be displayed on the page, but will be machine parsable.

Meta elements are typically used to specify page description, keywords, author of the document, last modified, and other metadata.

The metadata can be used by browsers (how to display content or reload page), search engines (keywords), or other web services.

<meta> tags always goes inside the <head> element.


The HTML <script> Element

The <script> tag is used to define a client-side script, such as a JavaScript.



« Previous Chapter                                                                                                                                          Next Chapter »




HTML Links :: futureX
Links are found in nearly all Web pages. Links allow users to click their way from page to page.

HTML Hyperlinks (Links)

The HTML <a> tag defines a hyperlink.

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.

The most important attribute of the <a> element is the href attribute, which indicates the link’s destination.

By default, links will appear as follows in all browsers:

An unvisited link is underlined and blue
A visited link is underlined and purple
An active link is underlined and red


HTML Link Syntax

The HTML code for a link is simple. It looks like this:

<a href="url">Link text</a>

The href attribute specifies the destination of a link.

Example

<a href="http://www.microsoft.com/">Visit Microsoft Official site</a>

which will display like this: Visit Microsoft Official site

Clicking on this hyperlink will send the user to Microsoft homepage.

Tip: The "Link text" doesn't have to be text. It can be an image or any other HTML element.

HTML Links - The target Attribute

The target attribute specifies where to open the linked document.

The example below will open the linked document in a new browser window or a new tab:

Example

<a href="http://www.microsoft.com/" target="_blank">Visit Microsoft Official</a>


HTML Links - The id Attribute

The id attribute can be used to create a bookmark inside an HTML document.

Tip: Bookmarks are not displayed in any special way. They are invisible to the reader.

Example

An anchor with an id inside an HTML document:

<a id="about">About Us</a>

Create a link to the "About Us" inside the same document:

<a href="#about">Visit the About Us Section</a>


Creating email Link :

Example

<p>
This is an email link:
<a href="mailto:someone@example.com?Subject=Hello%20again">
Send Mail</a>
</p>




« Previous Chapter                                                                                                                                          Next Chapter »



HTML Paragraphs

html paragraphs and line break :: futureX

Paragraphs are defined with the <p> tag.

Example

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

Note: Browsers automatically add an empty line before and after a paragraph.


  • Most browsers will display HTML correctly even if you forget the end tag:

Example

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

The example above will work in most browsers, but don't rely on it. Forgetting the end tag can produce unexpected results or errors.

Note: Future version of HTML will not allow you to skip end tags.

HTML Line Breaks


Use the <br> tag 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>

The <br> element is an empty HTML element. It has no end tag.

HTML Text Formatting



<!DOCTYPE html>
<html>
<body>

<p><b>This text is bold</b></p>
<p><strong>This text is strong</strong></p>
<p><i>This text is italic</i></p>
<p><em>This text is emphasized</em></p>
<p><code>This is computer output</code></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>

</body>
</html>


HTML Text Formatting Example :: futureX



HTML Formatting Tags

HTML uses tags like <b> and <i> for formatting output, like bold or italic text.


« Previous Chapter                                                                                                                                          Next Chapter »



HTML Headings

HTML Headings

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>


Note: Browsers automatically add some empty space (a margin) before and after each heading.

Importance of Headings

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.
               Since users may skim your pages by its headings, it is important to use headings to show the document structure.

H1 headings should be used as main headings, followed by H2 headings, then the less important H3 headings, and so on.



HTML Lines


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>


example of heading and lines :: futureX



HTML Comments


Comments can be inserted into the HTML code to make it more readable and understandable. Comments are ignored by the browser and are not displayed.

Comments are written like this:

Example

<!-- This is a comment -->

Note: There is an exclamation point after the opening bracket, but not before the closing bracket.



« Previous Chapter                                                                                                                                          Next Chapter »


HTML Attributes :: futureX

Attributes provide additional information about HTML elements.


HTML Attributes:


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

Example:

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


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


Attribute values should always be enclosed in quotes.

Double style quotes are the most common, but single style quotes are also allowed.

In some rare situations, when the attribute value itself contains quotes, it is necessary to use single quotes: name='John "Alfred" Nelson'


HTML Tip: Use Lowercase Attributes

Attribute names and attribute values are case-insensitive.

However, the World Wide Web Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4 recommendation.

Newer versions of (X)HTML will demand lowercase attributes.



« Previous Chapter                                                                                                                                          Next Chapter »




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


HTML elements :: futurex 




  Start tag                       Element content                               End tag

 <p>                                This is a example paragraph              </p>
 <a href="default.html">  This is a link                              </a>
 <br>  

 The start tag is often called the opening tag. The end tag is often called the closing tag.


HTML Element Syntax

An HTML element starts with a start tag / opening tag.
An HTML element ends with an end tag / closing tag.
The element content is everything between the start and the end tag.
Some HTML elements have empty content.
Empty elements are closed in the start tag.
Most HTML elements can have attributes.

Nested HTML Elements


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

HTML documents consist of nested HTML elements.

Example


<!DOCTYPE html>
<html>

<body>
<p>This is my first paragraph.</p>
</body>

</html>

Don't Forget the End Tag

Some HTML elements might display correctly even if you forget the end tag:

<p>This is a paragraph
<p>This is a paragraph
The example above works in most browsers, because the closing tag is considered optional.

Never rely on this. Many HTML elements will 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).

Tip: In XHTML, all elements must be closed. Adding a slash inside the start tag, like <br />, is the proper way of closing empty elements in XHTML (and XML).

HTML Tip: Use Lowercase Tags

HTML tags are not case sensitive: <P> means the same as <p>. Many web sites use uppercase HTML tags.

We use lowercase because the World Wide Web Consortium (W3C) recommends lowercase in HTML 4, and demands lowercase tags in XHTML.



« Previous Chapter                                                                                                                                          Next Chapter »


basic HTML :: futureX

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>
html heading example :: futureX

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://www.futurextech.blogspot.com">This is a link</a>



Note: The link address is specified in the href attribute.


HTML Images

HTML images are defined with the <img> tag.

Example

<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXGB1U7-60jnOvecQdP_Wqk5F3kJ5OOZOwAvC0zv-vkpHpIRIUBK68VzbvpdECUHAqRJz-84xpM9hupSCiT-GrD6zpDZVn6_UozjhTF6TBKhTshuAj8TPm9RLnug7nT5szSb3p8O3WMLfY/s1600/images.jpg" width="104" height="142">


Note: The filename and the size of the image are provided as attributes.




« Previous Chapter                                                                                                                                         Next Chapter »


What is HTML?

indroduction to HTML :: futureX
  • HTML is a language for describing web pages.
  • HTML stands for Hyper Text Markup Language
  • HTML is a markup language
  • A markup language is a set of markup tags
  • The tags describes document content
  • HTML documents contain HTML tags and plain text
  • HTML documents are also called web pages


HTML Tags


  • HTML markup tags are usually called HTML tags
  • HTML tags are keywords (tag names) surrounded by angle brackets like <html>
  • HTML tags normally come in pairs like <b> and </b>
  • 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>


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 purpose of a web browser (such as Google Chrome, Internet Explorer, Firefox, Safari) is to read HTML documents and display them as web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page.

HTML Versions

Since the early days of the web, there have been many versions of HTML:
Version                        Year
HTML                          1991
HTML+                        1993
HTML 2.0                    1995
HTML 3.2                    1997
HTML 4.01                  1999
XHTML 1.0                  2000
HTML5                        2012
XHTML5                      2013

The <!DOCTYPE> Declaration

The <!DOCTYPE> declaration helps the browser to display a web page correctly.
There are many different documents on the web, and a browser can only display an HTML page 100% correctly if it knows the HTML type and version used.

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

For a complete list of document type declarations, go to our DOCTYPE Reference.


« HTML Home                                                                                                                                                  Next Chapter »


Copyright © 2013 futureX | Blogger Template by Clairvo