Wednesday 21 September 2016

HTML for Begineers | PART :8


HTML for Begineers | PART  :8





HTML Links and Images
·        Links are nearly found in all the web pages. Links allows user to click their way from  page to page.
·        Images are of different – different  types.
Example- JPG images, GIF images, PNG images , etc.

HTML Link – Hyperlink

·        HTML Links are hyperlinks.
·        A hyperlink is a text or an image you can click on, and jump to another document.

HTML Links – syntax
In HTML , Links are defined with <a> tag :
<a herf= “url” >Link  text </a>

Example :
<a herf=
www.c-sharpcorner.com> c#corner </a>

·        The href attribute specifies the destination address (http://www.c-sharpcorner.com)
·        The link text is the visible part (c#corner).
·        Clicking on the link text, will send you to the specified address.

Local Links
The example above used an absolute URL (A full web address).
A local link (link to the same web site) is specified with a relative URL (without http://www....).

Example:
<a href="htmlimages.gif">HTML Images</a>

HTML Links - Colors and Icons
When you move the mouse cursor 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, links will appear as 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

HTML Links - The target Attribute

The target attribute specifies where to open the linked document.
This example will open the linked document in a new browser window or in a new tab:
Example:
<a href="http://www.c-sharpcorner.com/" target="_blank">Visit c#corner</a>

HTML Images



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 defines the url (web address) of the image:
<img src="url" alt="some_text">

The alt Attribute

·        The alt attribute specifies an alternate text for the image, if it cannot be displayed.
·        The value of the alt attribute should describe the image in words.
Example:
<img src="html5.gif" alt="The official HTML5 Icon">

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

HTML Screen Readers

·        Screen readers are software programs that can read what is displayed on a screen.
·        Used on the web, screen readers can "reproduce" HTML as text-to-speech, sound icons, or braille output.
·        Screen readers are used by 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 width and height attributes.
·        The values are specified in pixels (without px after the value):
Example:
<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">

Width and Height or Style?

·        Both the width, the height, and the style attributes, are valid in the latest HTML5 standard.
·        We suggest you use the style attribute. It prevents styles sheets from changing the default size of images:

Example:
<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 on the web, to store images in a sub-folder, and refer to the folder in the image name:
Example:
<img src="/images/html5.gif" alt="HTML5 Icon" style="width:128px;height:128px">

·        If a browser cannot find an image, it will display a broken link icon:
Example:
<img src="htmltags.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.google.com/images/google_gogreen.jpg">

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
It is common to use images as links:

Example:
<a href="default.asp">
  <img src="smiley.gif" alt="HTML" style="width:42px;height:42px;border:0>
</a>

Image Maps

For an image, you can create an image map, with clickable areas:

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>

Image Floating

You can let an image float to the left or right of a paragraph:

Example:
<p>
  <img src="smiley.gif" alt="Smiley face" style="float:left;width:42px;height:42px">
  A paragraph with an image. The image floats to the left of the text.
</p>

Chapter Summary
·        Use <a herf= “url” >Link  text </a> tag to link website.
  • Use the HTML <img> element to define images
  • Use the HTML src attribute to define the image file name
  • Use the HTML alt attribute to define an alternative text
  • Use the HTML width and height attributes to define the image size
  • Use the CSS width and height properties to define the image size (alternatively)
  • Use the CSS float property to let the image float
  • Use the HTML usemap attribute to point to an image map
  • Use the HTML <map> element to define an image map
  • Use the HTML <area> element to define image map areas

HTML for Begineers | PART : 9

HTML for Begineers | PART  : 9

In this article I’ll be discussing basic part of HTML that a junior (beginner) needs to know. From juniors I mean to all those who are who just passed High School or are of 14 years or above.



HTML Table Example

Number
First Name
Last Name
Points
1.
Siya
Singh
94
2.
Jack
 Sharma
80
3.
Aman
Jaiswal
67
4.
 Riya
 Gupta
50

Defining HTML Tables

·       Tables are defined with the <table> tag.
·       Tables are divided into table rows with the <tr> tag.
·       Table rows are divided into table data with the <td> tag.
·       A table row can also be divided into table headings with the <th> tag.
·       Table data contains all sorts of HTML elements like text, images, lists, other tables, etc.
Example :


<table style="width:50">
  <tr>
    <td>
Riya </td>
    <td>Gupta</td> 
    <td>50</td>
  </tr>
<tr>
    <td>
Jack </td>
    <td>Sharma</td> 
    <td>80</td>
  </tr>
</table>


An HTML Table with a Border Attribute

·       If you do not specify  border for the table,then it will be displayed without borders.
A border can be added using the border attribute:

EXAMPLE

<table border="1" style="width:100%">
  <tr>
    <td>
Riya </td>
    <td>Gupta</td> 
    <td>50</td>
  </tr>
  <tr>
    <td>Siya</td>
    <td>Singh</td> 
    <td>94</td>
  </tr>
</table>

To add borders, use the CSS border property:

EXAMPLE

table, th, td {
    border: 1px solid black;

}

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

An HTML Table with Collapsed Borders

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

Example


table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}

An HTML Table with Cell Padding
·       Cell padding is define as 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


table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 15px;
}


HTML Table Headings

·       Table headings are defined with the <th> tag.
By default, all major browsers display table headings as bold and centered:

Example


<table style="width:100%">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th> 
    <th>Points</th>
  </tr>
  <tr>
    <td>Siya</td>
    <td>Singh</td> 
    <td>94</td>
  </tr>
</table>

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

Example


th {
    text-align: left;
}


An HTML Table with Border Spacing

·       Border spacing is defined as the space between the cells.
To set the border spacing for a table, use the CSS border-spacing property:

Example


table {
    border-spacing: 5px;
}

·       If the table has collapsed borders,then border-spacing has no effect.


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

Example


<table style="width:100%">
  <tr>
    <th>Name</th>
    <th colspan="2">Telephone</th>
  </tr>
  <tr>
    <td>Bill Gates</td>
    <td>555 77 854</td>
    <td>555 77 855</td>
  </tr>
</table>


Table Cells that Span Many Rows

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

Example


<table style="width:100%">
  <tr>
    <th>Name:</th>
    <td>Bill Gates</td>
  </tr>
  <tr>
    <th rowspan="2">Telephone:</th>
    <td>555 77 854</td>
  </tr>
  <tr>
    <td>555 77 855</td>
  </tr>
</table>


An HTML Table With 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>
·       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>Points</th>
  </tr>
  <tr>
    <td>Siya</td>
    <td>Singh</td> 
    <td>94</td>
  </tr>
</table>

Now you can define special style for this table:


table#t01 {
    width: 100%; 
    background-color: #f1f1c1;
}

And add more styles:


table#t01 tr:nth-child(Siyan) {
    background-color: #eee;
}
table#t01 tr:nth-child(odd) {
    background-color: #fff;
}
table#t01 th {
    color: white;
    background-color: black;
}

Chapter Summary



  • Use  HTML <table> tag to define a table.
  • Use  HTML <tr>  tag to define a table row.
  • Use  HTML <td> tag to define a table data.
  • Use  HTML <th> tag to define a table heading.
  • Use  HTML <caption> tag to define a table caption.
  • Use  CSS border property to define a border.
  • Use  CSS border-collapse property to collapse cell borders.
  • Use  CSS padding property to add padding to cells.
  • Use  CSS text-align property to align cell text.
  • Use  CSS border-spacing property to set the spacing between cells.
  • Use colspan attribute to make a cell span many columns.
  • Use  rowspan attribute to make a cell span many rows.
  • Use  id attribute to uniquely define one table.

 For more visit my site "http://imshresthi.blogspot.in/"

HTML for Begineers | PART :8

HTML for Begineers | PART  :8 HTML Links and Images ·         Links are nearly found in all the web pages. Links allows ...