Pages

Sunday, 29 November 2020

Introduction to IP Addressing

IPV4

X.X.X.X                       32 Bits

X=8 Bits


MAC

X.X.X.X.X.X               48 Bits

X=8 Bits


IPV6

X.X.X.X.X.X.X.X        128Bits

X=16 Bits


  

IP address is an address having information about how to reach a specific host, especially outside the LAN. An IP address is a 32 bit unique address having an address space of 232

Generally, there are two notations in which IP address is written, dotted decimal notation and hexadecimal notation.

Dotted Decimal Notation:


Hexadecimal Notation:


Classful Addressing
                            The 32 bit IP address is divided into five sub-classes. These are:
Class A
Class B
Class C
Class D
Class E
Each of these classes has a valid range of IP addresses. Classes D and E are reserved for multicast and experimental purposes respectively. The order of bits in the first octet determine the classes of IP address.

IPv4 address is divided into two parts:
Network ID
Host ID
The class of IP address is used to determine the bits used for network ID and host ID and the number of total networks and hosts possible in that particular class. Each ISP (Internet Service Provider) or network administrator assigns IP address to each device that is connected to its network.

Note: IP addresses are globally managed by Internet Assigned Numbers Authority(IANA) and Regional Internet Registries(RIR).

Note: While finding the total number of host IP addresses, 2 IP addresses are not counted and are therefore, decreased from the total count because the first IP address of any network is the network number and whereas the last IP address is reserved for broadcast IP.

Class A
IP address belonging to class A are assigned to the networks that contain a large number of hosts.

The network ID is 8 bits long.
The host ID is 24 bits long.

The higher order bit of the first octet in class A is always set to 0. The remaining 7 bits in first octet are used to determine network ID. The 24 bits of host ID are used to determine the host in any network. The default subnet mask for class A is 255.x.x.x. Therefore, class A has a total of:

2^7-2= 126 network ID(Here 2 address is subracted because 0.0.0.0 and 127.x.y.z are special address. )
2^24 – 2 = 16,777,214 host ID
IP addresses belonging to class A ranges from 1.x.x.x – 126.x.x.x

Class B:
IP address belonging to class B are assigned to the networks that ranges from medium-sized to large-sized networks.

The network ID is 16 bits long.
The host ID is 16 bits long.
The higher order bits of the first octet of IP addresses of class B are always set to 10. The remaining 14 bits are used to determine network ID. The 16 bits of host ID is used to determine the host in any network. The default sub-net mask for class B is 255.255.x.x. Class B has a total of:

2^14 = 16384 network address
2^16 – 2 = 65534 host address
IP addresses belonging to class B ranges from 128.0.x.x – 191.255.x.x.

Class C:
IP address belonging to class C are assigned to small-sized networks.

The network ID is 24 bits long.
The host ID is 8 bits long.
The higher order bits of the first octet of IP addresses of class C are always set to 110. The remaining 21 bits are used to determine network ID. The 8 bits of host ID is used to determine the host in any network. The default sub-net mask for class C is 255.255.255.x. Class C has a total of:

2^21 = 2097152 network address
2^8 – 2 = 254 host address
IP addresses belonging to class C ranges from 192.0.0.x – 223.255.255.x.

Class D:
IP address belonging to class D are reserved for multi-casting. The higher order bits of the first octet of IP addresses belonging to class D are always set to 1110. The remaining bits are for the address that interested hosts recognize.

Class D does not posses any sub-net mask. IP addresses belonging to class D ranges from 224.0.0.0 – 239.255.255.255.

Class E:
IP addresses belonging to class E are reserved for experimental and research purposes. IP addresses of class E ranges from 240.0.0.0 – 255.255.255.254. This class doesn’t have any sub-net mask. The higher order bits of first octet of class E are always set to 1111.

Range of special IP addresses:

169.254.0.0 – 169.254.0.16 : Link local addresses
127.0.0.0 – 127.0.0.8 : Loop-back addresses
0.0.0.0 – 0.0.0.8 : used to communicate within the current network.


Problem :
consider the following subnet mask
255.255.254.0
1)Find the number of hosts per subnet 
2)Number of subnet if subnet mask belongs to class A
3)Number of subnet if subnet mask belongs to class B
4)Number of subnet if subnet mask belongs to class C
5)Number of subnet if total 10bits are used for global network ID


Problem:


Problem:
Answer:C


Problem:




Thursday, 26 November 2020

E-mail (Electronic mail)

           


 


Short for electronic mail, e-mail or email is information stored on a computer that is exchanged between two users over telecommunications. The first e-mail was sent by Ray Tomlinson in 1971

Email is a service which allows us to send the message in electronic mode over the internet. It offers an efficient, inexpensive and real time mean of distributing information among people.

E-Mail Address

Each user of email is assigned a unique name for his email account. This name is known as E-mail address. Different users can send and receive messages according to the e-mail address.

E-mail is generally of the form username@domainname. For example, webmaster@tutorialspoint.com is an e-mail address where webmaster is username and tutorialspoint.com is domain name.

The username and the domain name are separated by @ (at) symbol.

E-mail addresses are not case sensitive.

Spaces are not allowed in e-mail address.


The following rules make an e-mail address valid:

The username cannot be longer than 64 characters long, and the domain name cannot be longer than 254 characters.

There should be only one @ sign in an e-mail address.

The space and special characters: ( ) , : ; < > \ [ ] are allowed. Occasionally, a space, backslash, and quotation mark work but must be preceded with a forward slash. Although valid, some e-mail providers do not allow these characters.

The username and e-mail addresses as a whole cannot begin or end with a period.

The e-mail must not have two or more consecutive periods.

E-mail Header
The first five lines of an E-mail message is called E-mail header. The header part comprises of following fields:

From
Date
To
Subject
CC
BCC

From
The From field indicates the sender’s address i.e. who sent the e-mail.

Date
The Date field indicates the date when the e-mail was sent.

To
The To field indicates the recipient’s address i.e. to whom the e-mail is sent.

Subject
The Subject field indicates the purpose of e-mail. It should be precise and to the point.

CC
CC stands for Carbon copy. It includes those recipient addresses whom we want to keep informed but not exactly the intended recipient.

BCC
BCC stands for Black Carbon Copy. It is used when we do not want one or more of the recipients to know that someone else was copied on the message.

Greeting
Greeting is the opening of the actual message. Eg. Hi Sir or Hi Guys etc.

Text
It represents the actual content of the message.

Signature
This is the final part of an e-mail message. It includes Name of Sender, Address, and Contact Number.

Wednesday, 25 November 2020

How Does The Internet Works

 


To understand the Internet, it helps to look at it as a system with two main components. 
The first of those components is hardware. That includes everything from the cables that carry terabits of information every second to the computer sitting in front of you.
Other types of hardware that support the Internet include routers, servers, cell phone towers, satellites, radios, smartphones and other devices. All these devices together create the network of networks. 

Machines that store the information we seek on the Internet are servers. Other elements are nodes which serve as a connecting point along a route of traffic. And then there are the transmission lines which can be physical, as in the case of cables and fiber optics, or they can be wireless signals from satellites, cell phone or 4G towers, or radios.

All of this hardware wouldn't create a network without the second component of the Internet: the protocols. Protocols are sets of rules that machines follow to complete tasks. Without a common set of protocols that all machines connected to the Internet must follow, communication between devices couldn't happen. The various machines would be unable to understand one another or even send information in a meaningful way. The protocols provide both the method and a common language for machines to use to transmit data.

You've probably heard of several protocols on the Internet. For example, hypertext transfer protocol is what we use to view Web sites through a browser -- that's what the http at the front of any Web address stands for. If you've ever used an FTP server, you relied on the file transfer protocol. Protocols like these and dozens more create the framework within which all devices must operate to be part of the Internet.

Two of the most important protocols are the transmission control protocol (TCP) and the Internet protocol (IP). We often group the two together -- in most discussions about Internet protocols you'll see them listed as TCP/IP.

What do these protocols do? At their most basic level, these protocols establish the rules for how information passes through the Internet. Without these rules, you would need direct connections to other computers to access the information they hold. You'd also need both your computer and the target computer to understand a common language.

You've probably heard of IP addresses. These addresses follow the Internet protocol. Each device connected to the Internet has an IP address. This is how one machine can find another through the massive network.

The version of IP most of us use today is IPv4, which is based on a 32-bit address system. There's one big problem with this system: We're running out of addresses. That's why the Internet Engineering Task Force (IETF) decided back in 1991 that it was necessary to develop a new version of IP to create enough addresses to meet demand. The result was IPv6, a 128-bit address system. That's enough addresses to accommodate the rising demand for Internet access.

When you want to send a message or retrieve information from another computer, the TCP/IP protocols are what make the transmission possible. Your request goes out over the network, hitting domain name servers (DNS) along the way to find the target server. The DNS points the request in the right direction. Once the target server receives the request, it can send a response back to your computer. The data might travel a completely different path to get back to you. This flexible approach to data transfer is part of what makes the Internet such a powerful tool.

How data travels across the Internet
First you open your Web browser and connect to our Web site when you  do this, your computer sends an electronic request over your internet connection to your Internet Service Provider (ISP).The ISP routes the request to a server further up the chain on the Internet. Eventually the request will hit a Domain Name Server (DNS).

This server will look for a match for the domain name you've typed in (such as www.howstuffworks.com). If it finds a match, it will direct your request to the proper server's IP address. If it doesn't find a match, it will send the request further up the chain to a server that has more information.

The request will eventually come to our Web server. Our server will respond by sending the requested file in a series of packets. Packets are parts of a file that range between 1,000 and 1,500 bytes. Packets have headers and footers that tell computers what's in the packet and how the information fits with other packets to create an entire file. Each packet travels back up the network and down to your computer. Packets don't necessarily all take the same path -- they'll generally travel the path of least resistance.

That's an important feature. Because packets can travel multiple paths to get to their destination, it's possible for information to route around congested areas on the Internet. In fact, as long as some connections remain, entire sections of the Internet could go down and information could still travel from one section to another -- though it might take longer than normal.

When the packets get to you, your device arranges them according to the rules of the protocols. It's kind of like putting together a jigsaw puzzle. The end result is that you see this article.

This holds true for other kinds of files as well. When you send an e-mail, it gets broken into packets before zooming across the Internet. Phone calls over the Internet also convert conversations into packets using the voice over Internet protocol (VoIP). We can thank network pioneers like Vinton Cerf and Robert Kahn for these protocols -- their early work helped build a system that's both scalable and robust.




Monday, 9 November 2020

HTML NOTES

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> 

Note: Use HTML headings for headings only. Don't use headings to make text BIG or bold.

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.google.com">This is a link</a> 

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

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


HTML Elements

An HTML element usually consists of a start tag and end tag, with the content inserted in between:

<tagname>Content goes here...</tagname> 

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

<p>My first paragraph.</p> 

Start tag Element content End tag

<h1> My First Heading </h1>

<p> My first paragraph. </p>

<br>

HTML Horizontal Rules

The <hr> tag defines a thematic break in an HTML page, and is most often displayed as a horizontal rule.

The <hr> element is used to separate content (or define a change) in an HTML page:

Example

<h1>This is heading 1</h1>

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

<hr>

<h2>This is heading 2</h2>

<p>This is some other text.</p>

<hr> 

________________________________________

The HTML <head> Element

The HTML <head> element has nothing to do with HTML headings.

The <head> element is a container for metadata. HTML metadata is data about the HTML document. Metadata is not displayed.

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

 .....

 </body>

 </html>

Note: Metadata typically define the document title, character set, styles, links, scripts, and other meta information.


HTML Tip - How to View HTML Source

Have you ever seen a Web page and wondered "Hey! How did they do that?"

To find out, right-click in the page and select "View Page Source" (in Chrome) or "View Source" (in IE), or similar in another browser. This will open a window containing the HTML code of the page.

      

HTML Tag Reference

W3Schools' tag reference contains additional information about these tags and their attributes.

You will learn more about HTML tags and attributes in the next chapters of this tutorial.

Tag Description

<html>

Defines the root of an HTML document

<body>

Defines the document's body

<head>

A container for all the head elements (title, scripts, styles, meta information, and more)

<h1> to <h6>

Defines HTML headings

<hr>

Defines a thematic change in the content


HTML Paragraphs

The HTML <p> element defines a paragraph:

Example

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

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

Note: Browsers automatically add some white space (a margin) before and after a paragraph.


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 any extra spaces and extra lines when the page is displayed:

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>


Don't Forget the End Tag

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 do not rely on it.

Note: Dropping the end tag can produce unexpected results or errors.


HTML Line Breaks

The HTML <br> element defines a line break.

Use <br> if you want a line break (a new line) without starting a new paragraph:

Example

<p>This is<br>a paragraph<br>with line breaks.</p>

The <br> tag is an empty tag, which means that it has no end tag.


The Poem Problem

This poem will display as one line:

Example

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

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>

HTML Tag Reference

Tag Description

<p>

Defines a paragraph

<br>

Inserts a single line break

<pre>

Defines pre-formatted text

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 Color

The color property defines the text color for an HTML element:

Example

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

<p style="color:red;">This is a paragraph.</p>


HTML Fonts

The font-family property defines the font to be used for an HTML element:

Example

<h1 style="font-family:verdana;">This is a heading</h1>

<p style="font-family:courier;">This is a paragraph.</p>


HTML Text Size

The font-size property defines the text size for an HTML element:

Example

<h1 style="font-size:300%;">This is a heading</h1>

<p style="font-size:160%;">This is a paragraph.</p>


HTML Text Alignment

The text-align property defines the horizontal text alignment for an HTML element:

Example

<h1 style="text-align:center;">Centered Heading</h1>

<p style="text-align:center;">Centered paragraph.</p>

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>

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

Example

<strong>This text is strong</strong>

________________________________________

HTML <i> and <em> Elements

The HTML <i> element defines italic text, without any extra importance.

Example

<i>This text is italic</i>

The HTML <em> element defines emphasized text, with added semantic importance.

Example

<em>This text is emphasized</em>

Note: Browsers display <strong> as <b>, and <em> as <i>. However, there is a difference in the meaning of these tags: <b> and <i> defines bold and italic text, but <strong> and <em> means that the text is "important".

________________________________________

HTML <small> Element

The HTML <small> element defines smaller text:

Example

<h2>HTML <small>Small</small> Formatting</h2>

________________________________________

HTML <mark> Element

The HTML <mark> element defines marked or highlighted text:

Example

<h2>HTML <mark>Marked</mark> Formatting</h2>

________________________________________

HTML <del> Element

The HTML <del> element defines deleted (removed) text.

Example

<p>My favorite color is <del>blue</del> red.</p>

________________________________________

HTML <ins> Element

The HTML <ins> element defines inserted (added) text.

Example

<p>My favorite <ins>color</ins> is red.</p>

________________________________________

HTML <sub> Element

The HTML <sub> element defines subscripted text.

Example

<p>This is <sub>subscripted</sub> text.</p>

________________________________________

HTML <sup> Element

The HTML <sup> element defines superscripted text.

Example

<p>This is <sup>superscripted</sup> text.</p>

________________________________________

Test Yourself with Exercises!

            

________________________________________

Color Names

In HTML, a color can be specified by using a color name:

Example

Color

Name

 

Red

 

Orange

 

Yellow

 

Cyan

 

Blue

HTML supports 140 standard color names.

________________________________________

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.

For example, rgb(255,0,0) is displayed as red, because red is set to its highest value (255) and the others are set to 0.

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

Red

Green

Blue

255

0

0

Experiment by mixing the RGB values below:

Red      Green   Blue

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)

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)


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

HTML Links - Colors

When you move the mouse over a link, two things will normally happen:

The mouse arrow will turn into a little hand

The color of the link element will change

By default, a link will appear like this (in all browsers):

An unvisited link is underlined and blue

A visited link is underlined and purple

An active link is underlined and red

You can change the default colors, by using styles:

Example

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

________________________________________

HTML Links - The target Attribute

The target attribute specifies where to open the linked document.

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

This example will open the linked document in a new browser window/tab:

Example

<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a> 

Tip: If your webpage is locked in a frame, you can use target="_top" to break out of the frame:

Example

<a href="http://www.w3schools.com/html/" target="_top">HTML5 tutorial!</a> 

________________________________________

HTML Links - Image as Link

It is common to use images as links:

Example

<a href="default.asp">

  <img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;border:0;">

</a> 

Note: border:0; is added to prevent IE9 (and earlier) from displaying a border around the image (when the image is a link).

________________________________________

HTML Links - Create a Bookmark

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="tips">Useful Tips Section</h2>

Then, add a link to the bookmark ("Useful Tips Section"), from within the same page:

<a href="#tips">Visit the Useful Tips Section</a> 

Or, add a link to the bookmark ("Useful Tips Section"), from another page:

Example

<a href="html_tips.html#tips">Visit the Useful Tips Section</a> 

________________________________________

Chapter Summary

Use the <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> element (inside <a>) to use an image as a link

Use the id attribute (id="value") to define bookmarks in a page

Use the href attribute (href="#value") to link to the bookmark

HTML Images Syntax

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

The <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="url" alt="some_text" style="width:width;height:height;"> 

________________________________________

The alt Attribute

The alt attribute provides an alternate text for an image, if the 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).

If a browser cannot find an image, it will display the value of the alt attribute:

Example

<img src="wrongname.gif" alt="HTML5 Icon" style="width:128px;height:128px;"> 

The alt attribute is required. A web page will not validate correctly without it. 

________________________________________

HTML Screen Readers

A screen reader is a software program that reads the HTML code, converts the text, and allows the user to "listen" to the content. Screen readers are useful for people who are blind, visually impaired, or learning disabled.

________________________________________

Image Size - Width and Height

You can use the style attribute to specify the width and height of an image.

The values are specified in pixels (use px after the value):

Example

<img src="html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;"> 

Alternatively, you can use the width and height attributes. Here, the values are specified in pixels by default:

Example

<img src="html5.gif" alt="HTML5 Icon" width="128" height="128"> 

Note: Always specify the width and height of an image. If width and height are not specified, the page will flicker while the image loads.

________________________________________

Width and Height, or Style?

Both the width, height, and style attributes are valid in HTML5.

However, we suggest using the style attribute. It prevents internal or external styles sheets from changing the original size of images:

Example

<!DOCTYPE html>

<html>

<head>

<style>

img { 

    width:100%; 

}

</style>

</head>

<body>


<img src="html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">

<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">


</body>

</html>

________________________________________

Images in Another Folder

If not specified, the browser expects to find the image in the same folder as the web page.

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

________________________________________

Images on Another Server

Some web sites store their images on image servers.

Actually, you can access images from any web address in the world:

Example

<img src="http://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.com"> 

________________________________________

Animated Images

The GIF standard allows animated images:

Example

<img src="programming.gif" alt="Computer Man" style="width:48px;height:48px;"> 

Note that the syntax of inserting animated images is no different from non-animated images.

________________________________________

Using an Image as a Link

 To use an image as a link, simply nest the <img> tag inside the <a> tag:

Example

<a href="default.asp">

  <img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;border:0;">

</a> 

Note: border:0; is added to prevent IE9 (and earlier) from displaying a border around the image (when the image is a link).

________________________________________

Image Floating

Use the CSS float property to let the image float to the right or to the left of a text:

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

________________________________________

Image Maps

Use the <map> tag to define an image-map. An image-map is an image with clickable areas.

The name attribute of the <map> tag is associated with the <img>'s usemap attribute and creates a relationship between the image and the map.

The <map> tag contains a number of <area> tags, that defines the clickable areas in the image-map:

Example

<img src="planets.gif" alt="Planets" usemap="#planetmap" style="width:145px;height:126px;">


<map name="planetmap">

  <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">

  <area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">

  <area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">

</map>

________________________________________

Chapter Summary

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

Use the HTML <map> element to define an image-map

Use the HTML <area> element to define the clickable areas in the image-map

Use the HTML <img>'s element usemap attribute to point to an image-map


Defining an HTML Table

An HTML table is defined with the <table> tag.

Each table row is defined with the <tr> tag. A table header is defined with the <th> tag. By default, table headings are bold and centered. A table data/cell is defined with the <td> tag.

Example

<table style="width:100%">

  <tr>

    <th>Firstname</th>

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

Note: The <td> elements are the data containers of the table.

They can contain all sorts of HTML elements; text, images, lists, other tables, etc.

________________________________________

HTML Table - Adding a Border

If you do not specify a border for the table, it will be displayed without borders.

A border is set using the CSS border property:

Example

table, th, td {

    border: 1px solid black;

}

Remember to define borders for both the table and the table cells.

________________________________________

HTML Table - Collapsed Borders

If you want the borders to collapse into one border, add the CSS border-collapse property:

Example

table, th, td {

    border: 1px solid black;

    border-collapse: collapse;

}

________________________________________

HTML Table - Adding Cell Padding

Cell padding specifies the space between the cell content and its borders.

If you do not specify a padding, the table cells will be displayed without padding.

To set the padding, use the CSS padding property:

Example

th, td {

    padding: 15px;

}

________________________________________

HTML Table - Left-align Headings

By default, table headings are bold and centered.

To left-align the table headings, use the CSS text-align property:

Example

th {

    text-align: left;

________________________________________

HTML Table - Adding Border Spacing

Border spacing specifies the space between the cells.

To set the border spacing for a table, use the CSS border-spacing property:

Example

table {

    border-spacing: 5px;

}

Note: If the table has collapsed borders, border-spacing has no effect.

________________________________________

HTML Table - Cells that Span Many Columns

To make a cell span more than one column, use the colspan attribute:

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>

________________________________________

HTML Table - Cells that Span Many Rows

To make a cell span more than one row, use the rowspan attribute:

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>

________________________________________

HTML Table - Adding a Caption

To add a caption to a table, use the <caption> tag:

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>

Note: The <caption> tag must be inserted immediately after the <table> tag.

________________________________________

A Special Style for One Table

To define a special style for a special table, add an id attribute to the 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 <table> element to define a table

Use the HTML <tr> element to define a table row

Use the HTML <td> element to define a table data

Use the HTML <th> element to define a table heading

Use the HTML <caption> 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

________________________________________

Test Yourself with Exercises!

          

________________________________________

HTML Table Tags

Tag Description

<table>

Defines a table

<th>

Defines a header cell in a table

<tr>

Defines a row in a table

<td>

Defines a cell in a table

<caption>

Defines a table caption

<colgroup>

Specifies a group of one or more columns in a table for formatting

<col>

Specifies column properties for each column within a <colgroup> element

<thead>

Groups the header content in a table

<tbody>

Groups the body content in a table

<tfoot>

Groups the footer content in a table /td> 

HTML Lists

« Previous

Next Chapter »

 HTML List Example

An Unordered List:

Item

Item

Item

Item

An Ordered List:

1. First item

2. Second item

3. Third item

4. Fourth item


________________________________________

Unordered HTML List

An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.

The list items will be marked with bullets (small black circles) by default:

Example

<ul>

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul> 

________________________________________

Unordered HTML List - Choose List Item Marker

The CSS list-style-type property is used to define the style of the list item marker:

Value Description

disc Sets the list item marker to a bullet (default)

circle Sets the list item marker to a circle

square Sets the list item marker to a square

none The list items will not be marked

Example - Disc

<ul style="list-style-type:disc">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul> 

Example - Circle

<ul style="list-style-type:circle">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul> 

Example - Square

<ul style="list-style-type:square">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul> 

Example - None

<ul style="list-style-type:none">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul> 

________________________________________

Ordered HTML List

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

The list items will be marked with numbers by default:

Example

<ol>

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol> 

________________________________________

Ordered HTML List - The Type Attribute

The type attribute of the <ol> tag, defines the type of the list item marker:

Type Description

type="1" The list items will be numbered with numbers (default)

type="A" The list items will be numbered with uppercase letters

type="a" The list items will be numbered with lowercase letters

type="I" The list items will be numbered with uppercase roman numbers

type="i" The list items will be numbered with lowercase roman numbers

Numbers:

<ol type="1">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol> 

Uppercase Letters:

<ol type="A">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol> 

Lowercase Letters:

<ol type="a">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol> 

Uppercase Roman Numbers:

<ol type="I">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol> 

Lowercase Roman Numbers:

<ol type="i">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol> 

________________________________________

HTML Description Lists

HTML also supports description lists.

A description list is a list of terms, with a description of each term.

The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag describes each term: 

Example

<dl>

  <dt>Coffee</dt>

  <dd>- black hot drink</dd>

  <dt>Milk</dt>

  <dd>- white cold drink</dd>

</dl> 

________________________________________

Nested HTML Lists

List can be nested (lists inside lists):

Example

<ul>

  <li>Coffee</li>

  <li>Tea

    <ul>

      <li>Black tea</li>

      <li>Green tea</li>

    </ul>

  </li>

  <li>Milk</li>

</ul> 

Note: List items can contain new list, and other HTML elements, like images and links, etc.

________________________________________

Horizontal Lists

HTML lists can be styled in many different ways with CSS.

One popular way is to style a list horizontally, to create a menu:

Example

<!DOCTYPE html>

<html>

<head>

<style>

ul {

    list-style-type: none;

    margin: 0;

    padding: 0;

    overflow: hidden;

    background-color: #333333;

}


li {

    float: left;

}


li a {

    display: block;

    color: white;

    text-align: center;

    padding: 16px;

    text-decoration: none;

}


li a:hover {

    background-color: #111111;

}

</style>

</head>

<body>


<ul>

  <li><a class="active" href="#home">Home</a></li>

  <li><a href="#news">News</a></li>

  <li><a href="#contact">Contact</a></li>

  <li><a href="#about">About</a></li>

</ul>


</body>

</html> 

________________________________________

Chapter Summary

Use the HTML <ul> element to define an unordered list

Use the CSS list-style-type property to define the list item marker

Use the HTML <ol> element to define an ordered list

Use the HTML type attribute to define the numbering type

Use the HTML <li> element to define a list item

Use the HTML <dl> element to define a description list

Use the HTML <dt> element to define the description term

Use the HTML <dd> element to define the description data 

Lists can be nested inside lists

List items can contain other HTML elements 

Use the CSS property float:left or display:inline to display a list horizontally

________________________________________

Test Yourself with Exercises!

     

HTML List Tags

Tag Description

<ul>

Defines an unordered list

<ol>

Defines an ordered list

<li>

Defines a list item

<dl>

Defines a description list

<dt>

Defines the term in a description list

<dd>

Defines the description in a description list


Different Types of CSS

There are three ways of adding CSS style rules to HTML elements:        1. Inline — using the style attribute in HTML element 2. Internal — ...