Computer ScienceNEB 2076 (old course)

Explain the <OL tag and <img tag with its properties and values. [2.5+2.5]

5

Answer

Explanation of <OL> and <img> Tags with Properties and Values

1. <OL> Tag (Ordered List)

The <OL> tag in HTML is used to create an ordered list (numbered list). Each item in the list is marked with a number, letter, or Roman numeral by default.

Syntax:

<ol>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ol>

Key Properties and Attributes:

Attribute Description Example Values
type Specifies the type of numbering 1 (default), A, a, I, i
start Sets the starting number of the list start="5" (starts from 5)
reversed Reverses the order of the list reversed (numbers in descending order)

Example:

<ol type="A" start="3">
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ol>

Output:

C. First item
D. Second item
E. Third item

2. <img> Tag (Image)

The <img> tag in HTML is used to embed an image in a webpage. It is a self-closing tag and must include the src attribute to specify the image source.

Syntax:

<img src="image.jpg" alt="Description" width="200" height="150">

Key Properties and Attributes:

Attribute Description Example Values
src Specifies the path of the image src="logo.png"
alt Provides alternative text if the image fails to load alt="Company Logo"
width Sets the width of the image width="300" (in pixels)
height Sets the height of the image height="200" (in pixels)
title Adds a tooltip when hovering over the image title="Click for details"
border Adds a border around the image (deprecated in HTML5) border="2"
loading Specifies lazy loading for performance loading="lazy"

Example:

<img src="mountain.jpg" alt="Beautiful Himalayan View" width="400" height="300" title="Click to enlarge">

Note:

  • The src attribute is mandatory for the <img> tag.
  • Always include the alt attribute for accessibility and SEO.
  • Images can be stored locally or hosted online (e.g., src="https://example.com/image.jpg").

Discussion

Loading…

More Computer Science questions

All Computer Science old questions