liveBook · Manning

Separation of concerns

As explained in Tiny CSS Projects

Separation of concerns is a software design principle that divides a system into distinct sections with separate purposes.

Separation of concerns divides a program into distinct sections, each organized around a different purpose. On a web page, HTML supplies structure and content, CSS supplies presentation, and JavaScript supplies additional functionality. Keeping these responsibilities apart reduces duplication and makes code easier to maintain, extend, and test. section 1.1.1

A separated web implementation gains several practical advantages:

  • Centralizing styles in an external CSS file lets one change apply across multiple HTML pages. section 1.3.3
  • Avoiding repeated inline declarations keeps content and presentation from becoming tightly coupled. section 1.3.1
  • Separating responsibilities supports maintainability, extensibility, stability, and easier testing. section 1.1.1

External CSS in HTML

Keep the document focused on content and link presentation from a separate file: <link rel="stylesheet" href="styles.css">. By contrast, <h1 style="color: crimson">Title of our article</h1> places styling directly beside content and becomes difficult to manage when repeated across many elements. section 1.3.3 section 1.3.1

Figure 1.1 A breakdown of a web page

Use the page breakdown to see how HTML, CSS, and JavaScript divide responsibility within a web page. section 1.1.1

How Tiny CSS Projects covers it

How deep it goes
Explains the principle, benefits, and external-versus-inline CSS trade-offs without descending into detailed architecture or testing procedures.
Examples
Uses a crimson heading, repeated paragraph styling, an external stylesheet link, and a diagram of web-page responsibilities.
What it assumes
Assumes basic HTML familiarity while defining CSS, JavaScript, inline styles, and external stylesheet linking in context.
What you can do after
Apply it via external stylesheets to reduce repetition and maintain consistent presentation across HTML pages.
How it connects
Connects HTML, CSS, JavaScript, inline CSS, external stylesheets, responsive design, and adaptive design.

Also explained in

Compare how 22 books explain separation of concerns →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.