Questions
14 of 30
1How can you centre text vertically and horizontally inside a box?
2What is the use of the white-space property?
3How can you truncate text with an ellipsis (...) in CSS?
4How do you wrap or prevent wrapping of text in a container?
5How do you make text responsive across different screen sizes?
6How do you justify text using CSS?
7What does text-shadow do? Give an example.
8How can you apply multiple shadows to text?
9How do you apply gradients to text in CSS?
10How do you control text overflow in a fixed-width container?
11What is the difference between em, rem, and px when styling text?
12How does font-weight differ from <b> tag in semantic meaning?
13How does accessibility relate to text formatting in HTML?
14What’s the difference between semantic and non-semantic text formatting tags?
15How can you ensure consistent text appearance across different browsers?
16What is the difference between font-style, font-variant, and font-weight?
17What is the role of @font-face in web typography?
18How can you import custom fonts in CSS?
19What’s the impact of using web fonts on performance?
20How can you optimise text rendering for readability?
21How do you make text appear vertically (top-to-bottom) using CSS?
22How do you style only the first letter or first line of a paragraph?
23How do you create a drop cap effect?
24How can you highlight a selected text range dynamically?
25How do you make text glow or have a neon effect using CSS?
26What CSS properties can you use for text animations?
27How can you apply a gradient background only to the text and not the entire element?
28How can you apply different styles to different words in the same line?
29How do you prevent text selection on a webpage?
30How do you implement responsive typography (fluid text size)?
14 / 30

What’s the difference between semantic and non-semantic text formatting tags?

Semantic vs Non-Semantic Text Formatting in HTML & CSS

Semantic tags convey meaning about the content to browsers, search engines, and assistive technologies, while non-semantic tags only affect visual appearance without conveying any meaning.

Differences Between Semantic and Non-Semantic Tags
  1. 1

    Semantic Tags: <strong>, <em>, <mark>, <cite>, <abbr>

    • Indicate meaning or importance.
    • Improve accessibility and SEO.
    • Can be styled with CSS for visual emphasis.
  2. 2

    Non-Semantic Tags: <b>, <i>, <u>

    • Only apply visual styles (bold, italic, underline).
    • Do not convey meaning to assistive technologies.
    • Should be combined with CSS and semantic HTML for clarity.
Example: Semantic vs Non-Semantic

In this example, <strong> and <em> convey semantic meaning for assistive technologies, while <b> and <i> only change the appearance. Using CSS with semantic tags enhances both accessibility and design.

Key Takeaways
  1. 1

    Semantic tags provide meaning, non-semantic tags only affect style.

  2. 2

    Always prefer semantic tags for accessibility and SEO benefits.

  3. 3

    CSS can enhance visual presentation without replacing semantic meaning.

  4. 4

    Combine semantic HTML with CSS for both design and inclusivity.

Difficulty: 5/10
Topics: HTML semantics, accessibility, CSS styling

Scenario Questions

0-2 years experience
  1. 1

    If you need to make a piece of text bold on a landing page, would you use <b> or <strong>, and why?

  2. 2

    How would you style a paragraph to look like a heading without changing the HTML markup? What are the implications?

  3. 3

    What happens to screen readers when you replace a <strong> tag with a <span> styled with font-weight:bold?

2-5 years experience
  1. 1

    We have a legacy component that uses <i> for icons and <b> for emphasis. Users report accessibility issues. How would you refactor it?

  2. 2

    During a CSS refactor, a developer changed <em> to <span class='italic'> and the layout broke on some browsers. What could be causing that?

  3. 3

    Why might a page's SEO ranking drop after replacing <h1> with a <div class='title'> styled via CSS?

5-8 years experience
  1. 1

    Design a component library that enforces semantic markup while allowing flexible styling. What patterns would you use to prevent developers from falling back to non‑semantic tags?

  2. 2

    Our large‑scale documentation site needs to support theming without sacrificing semantics. How would you structure the CSS and HTML to keep both concerns?

  3. 3

    When migrating a monolith to a component‑based architecture, how do you handle existing non‑semantic tags to ensure accessibility and maintainability?

8+ years experience
  1. 1

    At the organization level, we want to audit all HTML for semantic correctness across dozens of services. What strategy, tooling, and governance would you propose?

  2. 2

    If we decide to deprecate all presentational tags (<b>, <i>, <u>) in favor of CSS, how would you plan the rollout to minimize risk and technical debt?

  3. 3

    Discuss the trade‑offs of enforcing strict semantic HTML in a fast‑moving startup versus a regulated‑industry product.

Follow-up Questions

  • Can you give an example where using a non‑semantic tag caused a real bug?
  • How would you convince a team to adopt semantic markup?
  • What metrics would you track to measure the impact of this change?