Class 10Computer ScienceFull chapter

HTML: Lists, Links and Images

Lists organise a page, links join pages into a website and images make the page worth looking at. Learn the tags, the attributes and the exact distinctions examiners ask for — with ready-to-type code for your practical file.

Ordered Lists: the type and start Attributes

Quick answer An ordered list numbers its items automatically; type changes the style of the marker and start changes the value it counts from.

A list is a set of items shown one below another, each carrying a marker such as a number or a bullet. HTML — HyperText Markup Language — gives you three kinds of list: the ordered list, the unordered list and the description list. This section deals with the first of them.

An ordered list is used when the order of the items carries meaning — the steps of a procedure, the positions in a merit list, the stages of booking a railway ticket. It is written with the container tag <ol> and closed with </ol>. Every item inside it is written with the list item tag <li> ... </li>. You never type the numbers yourself; the browser generates them.

<ol>
  <li>Open the IRCTC website</li>
  <li>Search for the train</li>
  <li>Enter the passenger details</li>
  <li>Pay using UPI or a debit card</li>
</ol>

This displays as items 1, 2, 3 and 4. Insert a new step in the middle or delete one, and the whole list renumbers itself. That automatic renumbering is the advantage an examiner expects you to state when asked why a list tag is better than typing numbers into a paragraph.

The type attribute changes the style of the marker. It is written inside the opening <ol> tag and applies to every item of that list. Its five values are: 1 for ordinary numbers (this is the default, used when you write no type at all), A for capital letters, a for small letters, I for capital Roman numerals and i for small Roman numerals. The letter values are case sensitive: type="A" produces A, B, C while type="a" produces a, b, c, and type="I" produces I, II, III while type="i" produces i, ii, iii. All five values above are valid; typing one of them in the wrong case simply gives the wrong style of marker, which is a common slip in the exam.

The start attribute tells the browser which value to begin counting from. Its value is always a plain number, even when the markers are letters or Roman numerals. So start="3" means the third marker of whichever style you chose — the numeral 3, the letter C, or the Roman numeral III. This is useful when a long list has been broken by a paragraph of explanation and the second part must carry on from where the first stopped.

<ol type="I" start="4">
  <li>Physics practical</li>
  <li>Chemistry practical</li>
  <li>Computer practical</li>
</ol>

Because the style is capital Roman and counting starts at 4, the three items are marked IV, V and VI. Note that start="IV" would be wrong; the number is what the attribute expects.

Two more points that examiners test. First, both attributes go on the opening <ol> tag, not on <li>. Second, an ordered list may hold ordinary text, other tags such as <strong>, images or even another list inside each <li>. A full-mark answer about ordered lists names the tag pair, says that each item is marked with <li>, names the attribute with its permitted values, and shows a two-line or three-line example.

Ordered list &lt;ol&gt; ... &lt;/ol&gt; Container tag for a numbered list
List item &lt;li&gt; ... &lt;/li&gt; One item; used inside &lt;ol&gt; and &lt;ul&gt;
type attribute type="1|A|a|I|i" Marker style; default is 1
start attribute start="3" Always a number, whatever the marker style
Remember
  • An ordered list uses &lt;ol&gt; ... &lt;/ol&gt; and each item uses &lt;li&gt; ... &lt;/li&gt;.
  • Use an ordered list only when the sequence of items matters; the browser numbers them automatically.
  • type takes 1, A, a, I or i; the default is 1 and the letter values are case sensitive.
  • start takes a plain number, so &lt;ol type="A" start="3"&gt; begins at C.
  • Both type and start are written in the opening &lt;ol&gt; tag and apply to the whole list.
  • Adding or deleting an &lt;li&gt; renumbers the list on its own — the main advantage of list tags.

Unordered Lists and Description Lists

Quick answer An unordered list bullets its items and can change the bullet with type; a description list pairs each term with its description using dl, dt and dd.

An unordered list is used when the items belong together but no order is intended — the subjects offered by a school, the facilities in a computer lab, the documents needed for admission. It is written with the container tag <ul> ... </ul>, and once again each item is a <li> ... </li>. The browser places a bullet before every item.

<ul type="square">
  <li>Birth certificate</li>
  <li>Transfer certificate</li>
  <li>Two passport size photographs</li>
</ul>

The type attribute on <ul> chooses the bullet shape and takes three values: disc, a filled round bullet, which is the default when no type is written; circle, a hollow round bullet; and square, a small filled square. These values are written in small letters. Note that <ul> has no start attribute — there are no numbers to start from. Present-day practice is to control bullet shapes through style rules rather than the type attribute, and the exact size and shade of a bullet differs slightly from browser to browser, but the attribute is still understood by browsers and is part of what you are expected to know.

The third kind of list is the description list, called a definition list in older books and in many CBSE textbooks; both names refer to the same tags. It is used where every entry has two parts — a term and its explanation. A glossary of computer words, a fee table showing each head and what it covers, or a list of subjects with their descriptions all fit this pattern. Three tags work together:

  • <dl> ... </dl> — the description list itself, the container.
  • <dt> ... </dt> — the description term, the word being explained.
  • <dd> ... </dd> — the description data, the meaning of that term.
<dl>
  <dt>LAN</dt>
  <dd>Local Area Network — a network within one building or campus.</dd>
  <dt>URL</dt>
  <dd>Uniform Resource Locator — the complete address of a page on the web.</dd>
</dl>

Browsers normally show the term at the left margin and indent the description below it, which is why a description list looks neater than a table for a short glossary. A single <dt> may be followed by more than one <dd> when a term has two meanings, and two <dt> tags may share one <dd> when two terms mean the same thing.

Examiners like the comparison, so keep it ready. An ordered list numbers its items and is for sequences; an unordered list bullets its items and is for collections; a description list has no marker at all and is for term-and-meaning pairs. The item tag is <li> in the first two but <dt> and <dd> in the third — writing <li> inside <dl> is wrong. A frequent slip is to think that <dd> must go inside <dt>; the two are separate tags, one after the other, both directly inside <dl>.

Unordered list &lt;ul&gt; ... &lt;/ul&gt; Bulleted list
Bullet style type="disc|circle|square" disc is the default
Description list &lt;dl&gt; ... &lt;/dl&gt; Also called a definition list
Term and data &lt;dt&gt; term &lt;/dt&gt; &lt;dd&gt; meaning &lt;/dd&gt; Both go directly inside &lt;dl&gt;
Remember
  • An unordered list uses &lt;ul&gt; ... &lt;/ul&gt; with &lt;li&gt; items and shows bullets, not numbers.
  • type on &lt;ul&gt; takes disc (default), circle or square; there is no start attribute for &lt;ul&gt;.
  • A description list (definition list) uses &lt;dl&gt;, with &lt;dt&gt; for the term and &lt;dd&gt; for its description.
  • &lt;dt&gt; and &lt;dd&gt; are separate tags placed one after the other directly inside &lt;dl&gt;.
  • Browsers usually indent the &lt;dd&gt; under its &lt;dt&gt;, which suits glossaries.
  • Use &lt;ol&gt; for sequence, &lt;ul&gt; for a plain collection and &lt;dl&gt; for term-and-meaning pairs.

Nesting One List Inside Another

Quick answer A list placed inside an li of another list produces sub-items; the inner list must open and close inside that li.

Nesting means placing one list inside another so that the inner list becomes a set of sub-items under one item of the outer list. A school website uses this constantly: a menu of sections, each section holding its own set of pages; a syllabus with subjects, each subject holding its chapters.

There is one rule to remember, and it is the rule that carries the marks. The inner list is written inside an <li> of the outer list, before that <li> is closed. A list placed directly inside <ol> or <ul>, as a neighbour of the <li> tags rather than inside one of them, is incorrect HTML even though a browser may still display something.

<ol type="I">
  <li>Science
    <ul type="circle">
      <li>Physics</li>
      <li>Chemistry</li>
      <li>Biology</li>
    </ul>
  </li>
  <li>Commerce
    <ul type="circle">
      <li>Accountancy</li>
      <li>Business Studies</li>
    </ul>
  </li>
</ol>

Read that code slowly. The word Science and the whole inner <ul> together form item I; the closing </li> comes only after </ul>. The browser shows I. Science with three hollow bullets indented below it, then II. Commerce with two.

Any list may be nested inside any other. An unordered list may sit inside an ordered list, an ordered list inside an unordered list, and a description list may hold a list inside a <dd>. Nesting may go more than one level deep, though a page becomes hard to read beyond two or three levels.

Two points about how the result looks. The indentation you type in the code has no effect on the display; HTML ignores the extra spaces and new lines. Indent your code anyway, because a nested list that is not indented is very hard to check for missing closing tags, and neatness of code is part of what a practical examiner sees. Second, if you do not write a type attribute, most browsers change the bullet automatically at each level — commonly a filled disc at the first level, a hollow circle at the second and a square at the third — but this is a default built into the browser rather than a rule of HTML, so it can differ between browsers. If you need a particular bullet, state it with the type attribute instead of relying on the default.

The mistakes to avoid when a nested list appears in a question paper are usually the same three. Closing the outer <li> too early, so the inner list falls outside its parent item. Forgetting the closing </ul> or </ol> of the inner list, which makes the rest of the page part of that list. And crossing the tags — writing </li> before </ul> when the <ul> was opened inside that <li>. Tags must close in the reverse order in which they were opened, exactly like brackets in a mathematics expression.

A quick way to check your own answer is to count: every <ol>, <ul> and <li> you open must have one closing tag, and the innermost tag you opened must be the first one you close.

Nesting rule &lt;li&gt; text &lt;ul&gt; ... &lt;/ul&gt; &lt;/li&gt; Inner list sits inside the outer &lt;li&gt;
Closing order &lt;/ul&gt; then &lt;/li&gt; Innermost tag closes first
Usual browser defaults disc → circle → square level · Varies by browser; set type to be sure
Remember
  • A nested list is written inside an &lt;li&gt; of the outer list, and that &lt;li&gt; is closed only after the inner list closes.
  • Any type of list may be nested inside any other, and nesting may be more than one level deep.
  • Tags must close in the reverse order of opening; crossing tags is a common exam error.
  • Indentation in the source code improves readability but does not change the display.
  • Many browsers change the default bullet at each nesting level, but that is a browser default, not an HTML rule.
  • Write the type attribute if a particular number or bullet style is required.

The Anchor Tag, href, and Absolute versus Relative Links

Quick answer The anchor tag creates a hyperlink and href holds the address; an absolute link gives the full URL while a relative link gives the path from the current file.

A hyperlink, usually shortened to link, is a piece of text or an image that takes the visitor to another document when it is clicked. Links are what turn a set of separate pages into a website, and the whole World Wide Web is built on them.

A link is written with the anchor tag, <a> ... </a>. The address of the destination is given by the href attribute, short for hypertext reference. Whatever you write between the opening and closing anchor tags is the link text — the part the visitor sees and clicks.

<a href="admission.html">Admission details</a>

By default browsers show link text underlined and in a different colour, and usually in another colour once the link has been visited. The exact colours are a browser setting and can be changed by the page author, so do not claim in an answer that links are always blue.

The address in href is a URLUniform Resource Locator, the complete address of a resource on the web. A full URL has a protocol, a domain name and a path, which may end in a file name, as in https://www.irctc.co.in/nget/booking. Here HTTPS is the protocol (HyperText Transfer Protocol Secure, the encrypted form of HTTP, the HyperText Transfer Protocol that carries web pages), www.irctc.co.in is the domain name and the rest is the path within that site.

An absolute link gives the complete URL, including the protocol and the domain name. It points at one fixed place on the internet and works from any page on any site. You must use an absolute link whenever the destination is on a different website.

<a href="https://www.irctc.co.in">Book a train ticket</a>

A relative link gives only the path from the folder of the current page to the destination file. It has no protocol and no domain name, so it can only reach files on the same site. Suppose a school website is arranged with index.html at the top, a folder pages holding fees.html and contact.html, and a folder images. Then, writing from index.html:

  • <a href="about.html">About us</a> — a file in the same folder, named directly.
  • <a href="pages/fees.html">Fee structure</a> — a file one folder down; the folder name and a forward slash come first.
  • <a href="../index.html">Home</a> — written from inside pages, where ../ means go up one folder.
  • <a href="/index.html">Home</a> — a leading forward slash means start at the top folder of this site.

Why prefer a relative link inside your own site? Because the whole site can be copied to another folder, another computer or another web server and every relative link still works, since the files keep the same positions with respect to each other. Absolute links would all have to be edited. Relative links are also shorter to type.

Three errors to avoid. Do not put a full path from your own computer, such as a drive letter and folder names, in href — that works only on the machine where the file was made and fails for every visitor. Do not leave out the closing </a>, or the rest of the page may become part of the link. And avoid spaces in file and folder names; use a hyphen instead, as in fee-structure.html. Remember also that path names are treated as case sensitive by many web servers, so Fees.html and fees.html may not be the same file once the site is published.

Anchor tag &lt;a href="page.html"&gt;Text&lt;/a&gt; href holds the destination address
Absolute link https://www.irctc.co.in/page.html Protocol + domain + path
Relative link pages/fees.html Path from the current file's folder
Up one folder ../index.html Two dots and a slash per level up
URL Uniform Resource Locator HTTP = HyperText Transfer Protocol
Remember
  • A hyperlink is made with &lt;a href="address"&gt;link text&lt;/a&gt;; href means hypertext reference.
  • URL stands for Uniform Resource Locator: protocol, domain name and path to the file.
  • An absolute link contains the full URL with protocol and domain, and is needed for another website.
  • A relative link gives only the path from the current file and works only within the same site.
  • ../ moves up one folder; a leading forward slash starts from the top folder of the site.
  • Relative links survive when the site is moved to another folder or server; absolute links would need editing.

Inserting Images: the img Tag and Its Attributes

Quick answer The img tag is an empty element whose src gives the picture's address, alt gives replacement text, and width, height and align control its size and placement.

An image is placed on a page with the image tag, <img>. It is an empty element, also called a void or single tag: it has no closing tag and no content between tags, because everything it needs is supplied by its attributes. In the XHTML style of writing it appears as <img ... />, with a slash before the closing angle bracket.

An important idea to state in an exam answer: the picture is not stored inside the HTML file. The HTML file holds only the address of the picture; when the page is opened, the browser fetches each image separately and places it where the tag appears. That is why a web page with many large images loads slowly, and why the images must be copied along with the HTML file when the site is moved.

<img src="images/annual-day.jpg" alt="Students at the annual day function"
     width="400" height="250">

src — short for source — is the compulsory attribute that gives the address of the image file. Without it there is nothing to show. The address follows the same rules as a link: it may be relative, such as logo.png or images/logo.png or ../images/logo.png, or it may be an absolute URL pointing at an image on another site. Keeping all pictures in one folder named images is the usual arrangement. If the path is wrong or the file has been renamed, the browser cannot find the picture and shows a broken-image marker along with the alt text.

alt — short for alternative text — is a short description of the picture in words. It is displayed in place of the image when the image cannot be shown, and it is read aloud by screen-reading software.

width and height set the displayed size of the image, measured in pixels (a pixel is one dot of the screen). Give both and the browser reserves exactly that much space before the picture arrives, so the text does not jump about while the page loads. If you set only one of the two, current browsers scale the other to keep the original proportion. If you set both carelessly, the picture is stretched or squashed: to enlarge or reduce an image without distortion, change width and height in the same ratio. Note also that these attributes change only the size on screen — the file that has to travel over the connection is just as big, so a large photograph should be resized in an image editor rather than shrunk with width and height.

align positions the image with respect to the text around it. The values left and right push the image to that side and let the text flow around it; top, middle and bottom line up a single line of neighbouring text with the top, centre or base of the image. This is a legacy attribute: newer standards expect the same effects to be produced by style rules, and how faithfully it is honoured can differ between browsers, so treat align as something to recognise and explain rather than to rely on.

A full-mark answer on the image tag says that <img> is an empty tag, names src as compulsory, names alt and explains it, and gives width and height in pixels — supported by one correct line of code.

Image tag &lt;img src="logo.png" alt="School logo"&gt; Empty tag; no &lt;/img&gt;
src src="images/photo.jpg" Compulsory: address of the file
Size width="400" height="250" pixels · Keep the ratio to avoid stretching
align align="left|right|top|middle|bottom" Legacy attribute; behaviour varies
Remember
  • &lt;img&gt; is an empty (single) tag — it has no closing tag and carries only attributes.
  • The HTML file stores only the address of the image; the browser fetches the picture separately.
  • src is compulsory and may hold a relative path or an absolute URL.
  • width and height are given in pixels; change both in the same ratio to avoid distortion.
  • Setting width and height reserves space so the layout does not shift while the page loads.
  • align takes left, right, top, middle or bottom; it is a legacy attribute and support varies by browser.

Quick reference

Every term, tag and rule from this chapter in one place — screenshot it before your exam.

&lt;ol&gt; ... &lt;/ol&gt;
Ordered list
&lt;li&gt; ... &lt;/li&gt;
List item
type="1|A|a|I|i"
type attribute
start="3"
start attribute
&lt;ul&gt; ... &lt;/ul&gt;
Unordered list
type="disc|circle|square"
Bullet style
&lt;dl&gt; ... &lt;/dl&gt;
Description list
&lt;dt&gt; term &lt;/dt&gt; &lt;dd&gt; meaning &lt;/dd&gt;
Term and data
&lt;li&gt; text &lt;ul&gt; ... &lt;/ul&gt; &lt;/li&gt;
Nesting rule
&lt;/ul&gt; then &lt;/li&gt;
Closing order
disc → circle → square
Usual browser defaultslevel
&lt;a href="page.html"&gt;Text&lt;/a&gt;
Anchor tag
https://www.irctc.co.in/page.html
Absolute link
pages/fees.html
Relative link
../index.html
Up one folder
Uniform Resource Locator
URL
&lt;a href="#fees"&gt;...&lt;/a&gt; with id="fees"
Same-page link
&lt;a href="fees.html#bus"&gt;
Section of another page
&lt;a href="mailto:office@school.edu.in"&gt;
Email link
&lt;a href="files/notes.pdf"&gt;
File link
target="_blank"
target attribute
&lt;img src="logo.png" alt="School logo"&gt;
Image tag
src="images/photo.jpg"
src
width="400" height="250"
Sizepixels
align="left|right|top|middle|bottom"
align
alt="Students at the annual day"
alt attribute
&lt;a href="index.html"&gt;&lt;img src="logo.png" alt="Home"&gt;&lt;/a&gt;
Image as a link
Joint Photographic Experts Group
JPEG
Portable Network Graphics
PNG
Graphics Interchange Format
GIF

Test yourself

Tap an answer to check it instantly — you'll see why it's right, and what to revise if it isn't.

0 correct · 0/12 answered
Q1 List tags easy

Which tag is used to mark each item inside both an ordered list and an unordered list?

Q2 type and start medium

What marker appears against the first item of &lt;ol type="I" start="5"&gt;?

Q3 Unordered lists easy

If no type attribute is written, what bullet does &lt;ul&gt; use by default?

Q4 Description lists medium

In a description list, which pair of tags is used for the term and its explanation?

Q5 Nesting lists hard

Which piece of code nests an unordered list correctly inside an ordered list?

Q6 Absolute and relative links medium

Which of these is an absolute link?

Q7 Relative paths medium

In &lt;img src="../images/logo.png"&gt;, what does ../ mean?

Q8 Linking within a page medium

A link is written as &lt;a href="#library"&gt;Library&lt;/a&gt;. For it to work, the page must contain:

Q9 mailto links easy

Which link opens the visitor's mail program with the school address filled in?

Q10 target attribute easy

What does target="_blank" do?

Q11 The alt attribute hard

Which statement about the alt attribute is NOT correct?

Q12 Image formats hard

A school badge has to appear on a coloured background without any white box around it. Which format is the most suitable?

NCERT solutions & previous-year questions

Step-by-step model answers — tap a question to reveal the full solution.

NCERT questions 8

1 What is an ordered list? Name the tags and attributes used with it, and give an example.Ordered lists

An ordered list is a list in which the items appear in a definite sequence and the browser places a number or letter before each item automatically. It is used where the order carries meaning, such as the steps of a procedure or the positions in a merit list.

Tags: <ol> ... </ol> encloses the list and <li> ... </li> marks each item.

Attributes of <ol>:

  • type — the style of the marker: 1 (numbers, the default), A, a, I or i.
  • start — a number giving the value to begin counting from.
<ol type="a" start="2">
  <li>Fill the online form</li>
  <li>Upload the documents</li>
  <li>Pay the fee using UPI</li>
</ol>

The three items are marked b, c and d.

2 Differentiate between an ordered list and an unordered list.Types of lists

Purpose: an ordered list is used when the sequence of the items matters; an unordered list is used when the items simply belong together and no order is intended.

Tag: an ordered list uses <ol> ... </ol>; an unordered list uses <ul> ... </ul>. Both use <li> for each item.

Marker: an ordered list shows numbers, letters or Roman numerals; an unordered list shows bullets.

type values: 1, A, a, I, i for <ol>; disc, circle, square for <ul>.

start attribute: available on <ol> only, because an unordered list has no counting to begin.

Example: the steps of booking a train ticket suit <ol>; the documents needed at admission suit <ul>.

3 What is a description (definition) list? Explain the three tags used and give an example.Description lists

A description list, called a definition list in older books, is a list in which every entry has two parts — a term and the description of that term. It suits a glossary, a list of abbreviations, or a fee table showing each head and what it covers.

  • <dl> ... </dl> — the container that holds the whole list.
  • <dt> ... </dt> — the description term.
  • <dd> ... </dd> — the description data, that is, the meaning.
<dl>
  <dt>HTTP</dt>
  <dd>HyperText Transfer Protocol, used to carry web pages.</dd>
  <dt>URL</dt>
  <dd>Uniform Resource Locator, the address of a page on the web.</dd>
</dl>

Browsers usually place the term at the left margin and indent its description below it. <dt> and <dd> are separate tags written one after the other inside <dl>; <li> is never used in a description list.

4 Explain what is meant by nesting of lists. State the rule to be followed and give an example.Nesting lists

Nesting means writing one list inside another so that the inner list forms sub-items under a single item of the outer list.

Rule: the inner list must be written inside an <li> of the outer list, and that <li> must be closed only after the inner list has been closed. Tags close in the reverse order of opening.

<ul>
  <li>Class 10 subjects
    <ol type="i">
      <li>Mathematics</li>
      <li>Science</li>
      <li>Computer Applications</li>
    </ol>
  </li>
  <li>Activities</li>
</ul>

The three subjects appear as i, ii and iii, indented under the first bullet. Indenting the source code does not change the display but makes missing closing tags easy to spot.

5 What is a hyperlink? Explain the anchor tag and the href attribute.Anchor tag

A hyperlink is text or an image on a web page which, when clicked, takes the visitor to another document, to another part of the same document, or to a resource such as a file or an email address. Hyperlinks are what join separate pages into a website.

A hyperlink is created with the anchor tag, <a> ... </a>. Its main attribute is href (hypertext reference), which holds the address of the destination. The text written between the opening and closing tags is the link text that the visitor sees and clicks.

<a href="admission.html">Admission details</a>

Browsers normally show link text underlined and in a distinct colour, and in a different colour after it has been visited; the exact colours are a browser setting and may be changed by the author. Forgetting the closing </a> can turn the rest of the page into part of the link.

6 Distinguish between an absolute link and a relative link. When is each used?Absolute and relative links

An absolute link contains the complete URL of the destination — the protocol, the domain name and the path — for example https://www.irctc.co.in/nget/booking. It identifies one fixed place on the internet and works from any page anywhere. It must be used when linking to a different website.

A relative link contains only the path from the folder of the current file to the destination, such as fees.html, pages/fees.html or ../index.html. It has no protocol and no domain name, so it can reach only files on the same site. It is used for links within your own website.

Advantages of a relative link: it is shorter to type, and it continues to work when the entire site is copied to another folder, another computer or another web server, because the files keep the same positions with respect to one another. Absolute links would all need editing after such a move.

In a relative path, ../ moves up one folder and a leading / starts at the top folder of the site.

7 How do you create a link to a particular section of the same web page? Explain with code.Linking within a page

Two steps are needed.

Step 1 — mark the destination. Give the element you want to jump to an id attribute with a unique name containing no spaces.

Step 2 — create the link. Write an anchor whose href is a hash symbol followed by that same name.

<p><a href="#library">Go to the library section</a></p>

<p id="library"><strong>Library</strong></p>
<p>The library remains open on all working days.</p>

Clicking the link scrolls the page to the paragraph whose id is library; no new page is loaded. The hash is written only in href, never in the id. To reach a section of a different page, write the file name first: <a href="fees.html#bus">Bus charges</a>. Such links are also called internal or bookmark links.

8 Name four image file formats used on web pages and state where each is suitable.Image formats
  • JPEG / JPG (Joint Photographic Experts Group) — best for photographs. It handles a very large range of colours and compresses strongly, but the compression is lossy and it supports neither transparency nor animation.
  • PNG (Portable Network Graphics) — best for logos, screenshots and diagrams. Its compression is lossless and it supports a transparent background, but photographs saved as PNG give much bigger files than JPEG.
  • GIF (Graphics Interchange Format) — best for small, simple graphics and short animations. It is limited to 256 colours, so it is unsuitable for photographs.
  • SVG (Scalable Vector Graphics) — best for logos, icons and line diagrams, because it stores shapes rather than dots and stays sharp at any size.

BMP may also be named, but it is largely uncompressed and produces very large files, so it is avoided on web pages.

Previous-year board questions 6

Q1 Write the HTML statement to insert an image named school.jpg, stored in a folder called images, with the alternative text "School building". 1 mark
<img src="images/school.jpg" alt="School building">

<img> is an empty tag, so no closing tag is written.

Q2 Write HTML code to display the following list of subjects using capital Roman numerals, beginning at III: Mathematics, Science, Computer Applications. 2 marks
<ol type="I" start="3">
  <li>Mathematics</li>
  <li>Science</li>
  <li>Computer Applications</li>
</ol>

The items are marked III, IV and V. Note that start takes the plain number 3, not the numeral III, and that type="I" must be a capital letter for capital Roman numerals.

Q3 Explain the target attribute of the anchor tag. Name its values and state what each does. 2 marks

The target attribute of <a> specifies where the linked document should be displayed.

  • _self — opens the page in the same window or tab, replacing the current page. This is the default.
  • _blank — opens the page in a new tab or a new window; which of the two appears is decided by the browser and its settings.
  • _parent — opens the page in the parent frame.
  • _top — opens the page in the full window, cancelling all frames.
<a href="https://www.irctc.co.in" target="_blank">IRCTC</a>

Every value begins with an underscore. _parent and _top are meaningful only on pages built with frames.

Q4 What is the alt attribute of the img tag? Give three reasons why it should always be written. 3 marks

The alt attribute supplies alternative text — a short description in words of what the image shows.

Reasons for writing it:

  • If the image cannot be displayed — a wrong path, a missing file, a slow connection or images switched off — the alt text appears in its place, so the visitor still learns what was meant to be shown.
  • Screen-reading software used by visitors who cannot see the screen reads the alt text aloud; without it, that part of the page is silent.
  • Search engines cannot read pictures, so the alt text tells them what the image contains and helps the page be found.
<img src="logo.png" alt="School logo" width="150" height="60">

The text should describe the content or purpose of the image; a decorative image may carry an empty alt="".

Q5 Differentiate between the GIF and JPEG image formats, giving one situation where each is preferred. 3 marks

Full forms: GIF is Graphics Interchange Format; JPEG is Joint Photographic Experts Group.

Colours: GIF supports at most 256 colours; JPEG supports a very large range of colours, which is why photographs look natural in it.

Animation: GIF can store a short animation; JPEG cannot.

Transparency: GIF supports simple transparency; JPEG does not.

Compression: JPEG uses lossy compression, so some detail is discarded and the file becomes small; GIF compression does not lose colours but the colour limit itself reduces quality for photographs.

Use: a photograph of the annual day function is best saved as JPEG; a small moving icon or a simple two-colour graphic is best saved as GIF.

Q6 Write the HTML code for a page named home.html that contains: (i) an unordered list of three facilities with square bullets, (ii) a link to another page notices.html that opens in a new tab, (iii) an email link to office@school.edu.in, and (iv) the image logo.png, stored in an images folder, acting as a link to index.html. 5 marks
<ul type="square">
  <li>Computer laboratory</li>
  <li>Library</li>
  <li>Playground</li>
</ul>

<p><a href="notices.html" target="_blank">Notice board</a></p>

<p><a href="mailto:office@school.edu.in">Write to the office</a></p>

<p>
  <a href="index.html">
    <img src="images/logo.png" alt="School home page"
         width="150" height="60">
  </a>
</p>

Points to note: type="square" is written in the opening <ul> tag; target="_blank" asks for a new tab or window; mailto: comes immediately before the address with no space; and the image becomes clickable because <img> is placed between <a> and </a>, with alt text naming the destination of the link.

Part of Priodemy for School

Interactive Maths & Science — free with every school on Priodemy EduSuite. Explore more chapters and labs on the Priodemy for School hub.

Ask AI