Back to the 2020 paper

Module I: Introduction to Web Technologies & Architectures

20207m

What are logical and physical tags in HTML? What is CSS?

Worked SolutionAI Assisted

Answer: Physical vs Logical Tags in HTML and Introduction to CSS

1. Physical vs. Logical Tags in HTML

HTML tags used for formatting text are historically categorized into Physical Tags and Logical Tags:

                               +-----------------------------+
                               |     HTML FORMATTING TAGS    |
                               +--------------+--------------+
                                              |
                     +------------------------+------------------------+
                     |                                                 |
                     v                                                 v
           +--------------------+                            +--------------------+
           |   PHYSICAL TAGS    |                            |    LOGICAL TAGS    |
           | (Visual Appearance)|                            | (Semantic Meaning) |
           |  <b>, <i>, <u>     |                            | <strong>, <em>     |
           +--------------------+                            +--------------------+

A. Physical Tags

  • Definition: Physical tags tell the browser strictly how to visually render the enclosed text (its appearance/style) without conveying any semantic meaning, importance, or context.
  • Characteristics: Focused entirely on visual layout; ignored by assistive screen readers in terms of vocal inflection.
  • Examples:
    • <b>Text</b>: Renders text in bold style.
    • <i>Text</i>: Renders text in italicized style.
    • <u>Text</u>: Underlines the text.
    • <s>Text</s> or <strike>: Renders text with a strikethrough line.
    • <tt>Text</tt>: Displays text in fixed-width teletype font.
    • <sub> / <sup>: Subscript and superscript formatting.

B. Logical Tags (Semantic Tags)

  • Definition: Logical tags describe the semantic meaning, purpose, or structural importance of the enclosed content to the browser, search engines, and screen readers.
  • Characteristics: The browser standardly provides default formatting (e.g., <strong> is bolded, <em> is italicized), but screen readers adjust voice tone and emphasis accordingly.
  • Examples:
    • <strong>Text</strong>: Indicates strong importance or urgency (default rendered as bold).
    • <em>Text</em>: Indicates emphasized stress (default rendered as italic).
    • <code>Text</code>: Defines a snippet of computer code (monospace).
    • <cite>Text</cite>: References the title of a creative work or author.
    • <mark>Text</mark>: Highlights relevant text for reference.
    • <abbr title="World Health Organization">WHO</abbr>: Defines an abbreviation or acronym.

C. Comparison Table

Parameter Physical Tags Logical (Semantic) Tags
Focus Visual appearance and styling Meaning, context, and structural value
Accessibility (Screen Readers) Treated as normal text without vocal change Read with appropriate vocal stress and emphasis
SEO Impact Minimal search engine value High value for search engine indexers
W3C Recommendation Deprecated in modern HTML5 (use CSS instead) Strongly recommended in modern semantic HTML
Examples <b>, <i>, <u>, <tt>, <big> <strong>, <em>, <code>, <cite>, <abbr>

2. What is CSS (Cascading Style Sheets)?

CSS (Cascading Style Sheets) is a style sheet language used to describe the visual presentation, layout, colors, typography, and responsive design of a document written in HTML or XML.

CSS Rule Syntax:

/* Selector { Property: Value; } */
h1 {
  color: #b23a2e;
  font-size: 24px;
  text-align: center;
}

Three Ways to Apply CSS in HTML:

  1. Inline CSS: Applied directly to an element via the style attribute:
    <p style="color: red; font-size: 14px;">Inline Styled Text</p>
    
  2. Internal (Embedded) CSS: Written inside <style> tags within the <head> section:
    <style>
      body { background-color: #f5f6f2; }
    </style>
    
  3. External CSS (Best Practice): Stored in a separate .css file and linked in <head>:
    <link rel="stylesheet" href="styles.css">
    

Key Benefits of CSS:

  • Separation of Content and Design: Keeps HTML clean and easy to maintain.
  • Faster Page Load: External stylesheets are cached by browsers.
  • Responsive Layouts: Media queries (@media) allow dynamic adaptation across mobile, tablet, and desktop viewports.

Similar questions