Class X CH-4 HTML Images, Links and Tables
Class X CH-4 HTML Images, Links and Tables
A. Inserting Images-Images are used to beautify as well as to depict many concepts easily on our webpages.
Images can improve the design and the appearance of a web page.
There are two types of images – Inline and External images.
Inline image
Inline image is displayed when the web page is opened and is inserted within a line of text. The simplest way to
add an inline image in HTML is to insert the <img> tag into the text exactly you want the image to appear.
The HTML <img> tag is used to embed an image in a web page. Images are not technically inserted into a web
page, images are linked to web pages. The <img> tag creates a holding space for the referenced image.
External image
The external image is not displayed automatically with other content on the web page. Instead, it is referenced
externally and viewed separately by clicking on a link. To add an external image in HTML document the anchor
<A> tag is used.
The <img> tag
The <img> tag is used to embed an image in a web page. The <img> tag is an empty tag (Not required closing tag),
and requires different attributs to be specified it.
The <img> tag has two required attributes:
src - Specifies the path or source of the image (While specifying image address, one should be well aware
of its location, i.e. where the file is stored.)
alt - Specifies an alternate text for the image
If the browser of the user’s computer does not displayed images due to some reason (due to slow
connection, an error in the src attribute, unsupportive browser, heavy traffic, or large size of an image), in
that case we can display the text to describe the image.
We can use the width and height attributes to specify the size of an image.
Example
<img src="myhouse.jpg" alt="This is my house" width="500" height="600">
Aligning inline images inline images are placed middle of the line f text. The align attribute specifies the
alignment of an image according to the surrounding element.
Aligning floating image: It will place the image against left or right margin.
To change its position we can use
Align=Top | Middle | Bottom | Left | Right
Image Floating Use the CSS float property to let the image float to the right or to the left of a text:
Like:<P> <img src=”smiley.gif” style=Float:right> The image is right to the text</p>
<P> <img src=”smiley.gif” style=Float:left> The image is left to the text </P>
To make image in center we can use <Center> element.
Use the HTML< border> attribute to add border to the image.
Use the HTML Hspace and Vspace to edit the amount of horizontal or vertical space respectively around the image.
<center>
<img src=”myhouse.jpeg” align=”right” hspace=30 vspace=40 height=200 width=200 border=4>
</center>
To make image as a link To make an image to act as a link use <img src> tag within the <A Href> tag.
To create an e-mail link Syntax <A Href = “mailto:mail address”>kips learnig Solution </A>
To insert audio
Syntax: <A Href = “URL of audio file”> Link text </A>
<Audio src=”url of audio file”></Audio>
<embed src=”URL of audio or video file”></Embed>
<embed src="video.mp4" width="400" height="300"> </embed>
<embed src="Audio.mp3"> </embed>
Attributes
Attribute Value Description
autoplay autoplay Specifies that the audio will start playing as soon as it is ready
controls controls Specifies that audio controls should be displayed (such as a play/pause button etc)
loop loop Specifies that the audio will start over again, every time it is finished
Ex.
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
To insert video Syntax: <AHref = “URL of vedio file”> Link text </A>
<Video src=”URL of Video file”></Video>
Attribute Value Description
autoplay autoplay Specifies that the video will start playing as soon as it is ready
controls controls Specifies that video controls should be displayed (such as a play/pause button etc).
loop loop Specifies that the video will start over again, every time it is finished
muted muted Specifies that the audio output of the video should be muted
<html>
<body>
<h1>The video element</h1>
<video width="320" height="240" Controls autoplay>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
</body>
</html>
Tables
Attributes of Table
The table attribute are defined with the table tag itself.
Syntax: <Table attribute_name: value>
value is the possible values of the respective attribute.
To apply border use <Table border=value> , value is size of border in pixel
To apply border colour use <Table Bordercolor= value> , value is colour name or RGB code.
To apply effects to outerborders of table use <Table Frame = value> , values frame attribute value
To apply effects to inner borders of table use <Table Rule = value> , values rule attribute value
To apply background colour to the table use <Table Bgcolor= value> , value is colour name or RGB code.
To apply background image to the table use <Table Background = value> , value is path of image
The align attribute aligns the text within the cell either to the left, right or center.(default property-Left align)
To align the table on the web page use <Table Align= value> , values are various align attribute value.
To set margins within a cell. It sets the amount of space between the cell border and cell data. i.e. cell padding use
<table cellpadding= value>, value is size in pixel
Cell Spacing. Cell spacing is the space between each cell. By default the space is set to 2 pixels.
To set height and width of the table use <Table Height = value Width= value> , value is size in pixel
To apply background colour to the table row use <Tr Bgcolor= value> , value is colour name or RGB code.
To apply background colour to the column heading use <Th Bgcolor= value> value is colour name or code.
To apply background colour to the table data <Td Bgcolor= value> , where value is colour name or RGB code.
To align the text within the cell use <Td align= value> , values are various align attribute value.
To set the vertical alignment(Top,bottom,middle) of data in a column use <Td Valign= value> values are various
Valign attribute value.
To merge(span) cells horizontally in a column use <Td Colspan= value> value is no of cells in span across
To merge(span) cells vertically in a row use <Td Rowspan= value> value is no of cells in span across
To set height and width of the table row use <Tr Height = value> <Tr Width= value> value is size in pixel
Frame-The frame attribute was used on the <table> element to control the display of the outside border. The value
frame="hsides" indicated that borders should be drawn on the top and bottom of the table. This attribute is
deprecated in HTML5 and should no longer be used. To achieve border effects on tables, use CSS.
Rules Attribute:- The rules attribute specifies which parts of the inside borders that should be visible. The purpose of the
HTML rules attribute is to specify which rulings (between rows and columns) are to be shown in a table. Value
Values Description
THEAD> tag
It is used to group header rows that define the table’s header. This tag should appear inside the <table> tag.
It is useful in case of larger tables that span across multiple pages in a document. The table header defined using
<THEAD>tag will appear on each page of the document where the tables is displayed.It is also a continer tag
Various attributes of <THEAD> are:-
Align- To set horizontal alignment
Valign- To set vertical alignment
Char- To specify the character to which the content in the table header will be aligned
Bgcolor- To set the background colour
<TBODY>
The <TBODY> tag defines a table’s body. It allows you to group a block of table rows in HTML table. IF you use the <TBODY>
tag, it must be used as s childof a <Table> element.
<TFOOT> tag
The<TFOOT> tag defines a group of footer rows in a table. A table footer provide footnotes at the bottom of a table.A table
canhave only one <TFOOT> tag which must appear after the <THEAD> and <TBODY> tag.
Revision Questions
1. Write the attributes of table tag?
2. Difference between<UL> and <Ol>?
3. What are frame boxes and rules?
4. Define rowspan and colspan.
5. What are the different attributes of table tag?
6. Which tag is used to change the type of ordered list?
7. Which property helps in specifying the placement of a table caption?
8. Define nested list. Which property helps in specifying space between the border and the cell content in a
table.
9. Write the uses of following tags:
<TD>, <TH>, <TR>, <DD>, <DL>