Ways to Add CSS — CSS Technical Interview Questions & Answers

Inline, internal and external stylesheets.

Ways to Add CSS

  • Inline, internal and external stylesheets.
  • CSS is the look of the page: colour, size, space, layout. HTML says ‘this is a heading’. CSS says ‘make headings navy and 28px’. You write rules: selector { property: value; }
  • h1 { color: navy; } changes every h1. .card { padding: 16px; } is a class. #logo is an id. Prefer classes for styling.
  • Trap: inline style on every tag. Trap: thinking CSS is a programming language with if/loops (it isn’t; you can get clever with queries, but start with rules).

Technical Interview Tip: h1 { color: navy; } — HTML structure, CSS look.

Code Examples for Ways to Add CSS

Ways to Add CSS — working example

/* Same declarations can be applied in three places: */

/* 1) Inline HTML: <p style="color: #b91c1c; font-weight: 700;">Warning</p> */

/* 2) Internal: inside <style> in <head> */
.lead {
  font-size: 1.125rem;
  color: #334155;
  line-height: 1.6;
}

/* 3) External styles.css (preferred for multi-page sites)
   <link rel="stylesheet" href="/styles.css" /> */
.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: #ffffff;
  text-decoration: none;
  border-radius: 0.375rem;
}

Ways to Add CSS — inline styles one element; internal <style> covers one page; external .css files are shared and cached.

How to Explain Ways to Add CSS to an Interviewer

What is CSS?

Style language for HTML selector { property: value; }