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 list item inside <OL> is marked with a number by default, starting from 1.

<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>
HTML `<ol>` tag structure with nested `<li>` elements (start=1)

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 numbering reversed (counts down)

Example:

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

Output:

A. First item
B. Second 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.

src="images/photo.jpg"Optimized loadHTML FileImage FolderBrowser Cache
How `src` paths work: local (relative) vs. remote (absolute)

Syntax:

<img src="image.jpg" alt="Description">

Key Properties and Attributes:

Attribute Description Example Values
src Specifies the path of the image src="logo.png"
alt Provides alternative text for accessibility alt="Company Logo"
width Sets the width of the image width="200"
height Sets the height of the image height="100"
title Displays a tooltip when hovering title="Click to zoom"
loading Controls lazy loading loading="lazy"

Example:

<img src="mountain.jpg" alt="Beautiful Mountain" width="300" height="200" title="Click to view">

Best Practices:

  • Always include the alt attribute for accessibility.
  • Use relative or absolute paths for src.
  • Optimize image size to improve page loading speed.

016324863<img> Tag32 bitsKey Attributes32 bitsBest Practices64 bits
Real-world `<img>` tag structure with attributes and best practices

Discussion

Loading…

More Computer Science questions

All Computer Science old questions