Leanpub Header

Skip to main content

Topics

HTML and CSS

From elements, attributes and semantics to selectors, the cascade, flexbox, grid, animation and the craft of writing less markup, HTML and CSS as told through the free samples of the Leanpub books about them.

Created from the free samples of 14 Leanpub books and the descriptions and tables of contents of 12 more, with every source cited.

HTML and CSS are the two languages in which web pages are written. HTML, the HyperText Markup Language, describes the content of a page through elements for headings, paragraphs, images, links and the rest; CSS, Cascading Style Sheets, describes how those elements look and where they sit. An introduction on this shelf lists them with the two other languages of the web, one for vector shapes and one for programming, and shows the smallest unit of the first: a paragraph, made of an opening tag, some content and a closing tag, which the browser draws according to the kind of element it is.[11]

Both languages are easy to begin and hard to finish, and the books about them divide along that line. A few teach the first steps. More of them, and the more distinctive, are about craft: one author, who accounts for eight of the twenty books here that are squarely on the subject, holds that HTML only looks easy, and supports the claim with the number of elements in the language, which few developers could list, and with the habit of calling elements tags.[1] The same author treats the optimisation of CSS as a matter of quality owed to the user and a mark of the professional.[6]

This article covers where to begin, the history, what the two languages are, HTML as a craft, the quality and architecture of CSS, layout, animation and graphics, and the technologies round the page. Its sources are the free samples of the Leanpub books listed at the end, with the descriptions and tables of contents of the books whose samples were not available, and every claim that rests on a source is cited to it.

Where to start

A complete beginner has Zero to Website, a long guide to building websites from nothing, including pages that adapt to the size of the screen,[20] and Intro to Software Development (2018), a free book whose finished part introduces the front end to readers who need only be confident users of a computer.[12] Fundamentals of HTML, SVG, CSS and JavaScript for Data Visualisation (2025) is a short introduction for people who work with data in other tools and need just enough of the web's languages to draw with them, and it lets the reader experiment in an online editor before installing anything, on the view that little can be broken there and that experiment teaches well.[11] Coding Challenges and Solutions - The Smartest Way to Learn Html and CSS is a workbook of questions for beginners who want practice, beginning with file names, the first elements, selectors and the linking of a style sheet.[13]

For layout, the quickest books are the pictures: Visual CSS Flexbox and Visual CSS Grid are cheat sheets with one illustration for each value of each property,[16][17] and CSS Flexbox and The CSS Grid Guidebook, from the same publisher, are short references built on examples that can be run live, which ask for familiarity with the two languages and urge the reader to type the examples out instead of only reading them.[9][10]

Developers who already write both languages daily are the readers of the craft books. Upgrade Your HTML and its four successors say that they do not teach HTML from the beginning,[1][5] CSS Optimization Basics is about writing better CSS,[6] Enduring CSS (2016) is about organising it in large projects,[21] and Idiosyncrasies of the HTML parser is an advanced account of how a browser reads markup.[22]

History

HTML was devised at the start of the 1990s as a simple language for linked documents, and CSS followed in 1996 to separate presentation from content. For a decade browsers disagreed about both, and pages were laid out with tables and invisible images. A stricter reformulation of HTML was attempted in the 2000s and abandoned; the version that succeeded it, with elements for sections, media and forms, has since been maintained as a continuously revised standard. CSS grew by modules, and two of them, for flexible boxes and for grids, at last gave it real tools for layout in the 2010s.

The books carry traces of each period. The first Upgrade Your HTML, begun in 2019, notes that the language would shortly be thirty years old, that the last numbered recommendation from one standards body defined 111 elements, and that the standard is now maintained by another group.[1] The fifth book in the series puts the printed length of the present specification at 1,463 pages, and its first example is markup of 2007 in which a table had been imitated with spaces and line breaks.[5] Flexbox Website (2015) is a workshop from the years when flexible boxes were new,[23] and The Little Book of Little Books republishes three booklets of 2015 and 2016, on frameworks, coding guidelines and quality control, with their links repaired and their forewords dropped, as what the author calls the books' afterlife.[7] Rote Learning HTML & CSS takes the long view of where authority lies: it tells the reader to learn the addresses of the two specifications by heart, to consult them first, and to weed out older versions and sources that are not authoritative.[8]

What the two languages are

Fundamentals of HTML, SVG, CSS and JavaScript for Data Visualisation gives the division of labour in four sentences: HTML describes the content of a page, the vector language describes shapes such as circles and lines, CSS describes style, such as the weight, colour and size of type, and position, and the programming language manipulates the others and handles interaction. Its chapter on HTML teaches five elements, headings in six levels, lists, images, a generic container and the element that holds drawings, on the ground that there are a great many elements and that, for the purpose of drawing charts, much can be done with few; the browser, it notes, decides how each is styled unless told otherwise.[11]

Intro to Software Development approaches the same ground through a list of tasks built up step by step. Its contents show the order of a first course: a page as its user sees it and as the browser sees it, attributes, then style, with rules, selectors and properties, the principle of the cascade by which competing rules are resolved, the style sheet that the browser itself applies, and the box model of margin, border and padding, inspected with the browser's own tools. Before any markup it explains what a website is: a program that many people load at once through their browsers, the client, and behind it a part that users never see, the server, which stores their data and sends each client what it asks for. The book is the surviving portion of a course meant to follow one application through the whole process of development, and its author keeps it free.[12] Rote Learning HTML & CSS offers the opposite of explanation, long lists of elements, attributes, selectors and properties with no examples and no context, on the theory that a reader who reviews the raw material even once will notice things that tutorials never showed. It describes itself as one of the most boring books a reader will meet, and means the boredom as a method.[8] The adjacent The Web Development Glossary defines several thousand terms of the field alphabetically.[19]

HTML as a craft

The premise of the Upgrade Your HTML series is that not everyone writes good HTML, chiefly because the language is more complex than it appears. Each booklet takes ten pieces of markup from live websites, made anonymous because the purpose is not to point fingers, and improves them. The first example is a link from a news site carrying a title that repeats its own text, and the lesson drawn is to use that attribute sparingly, only where context and content do not give enough, since it is cheap to type and costly to maintain. Other lessons are noted in passing: an attribute that could be dropped, and class names which, after passing through a build tool, are long and yet say very little.[1] The second booklet opens with a link for sharing a page, which arrives with three relationship values, four classes and two empty child elements, and asks what the purpose requires: one link. Its author names the approach minimal web development, in which each piece of code must show that it is necessary, and describes the spirit of the series as constructive, fair and playful.[2]

The same series returns to a method of economy that it says almost nobody uses, leaving out the markup that the standard allows to be omitted. The foreword to the fourth booklet, whose writer is also the author of the book on the HTML parser cited below, argues that because the rules for reading HTML are well defined and implemented alike in browsers, there is no harm in omitting optional tags provided the result is checked with a validator, though a writer trained in the stricter syntax of an earlier decade may at first find it uncomfortable; the habit it recommends is being critical of one's own markup and reading the standard. The booklet's first case is a heading of a level that does not exist.[4] The third restates the series' argument and adds that correct terminology still needs watching and that the language cannot be called mastered. Its first example is the navigation list of a government website, weighed down by the number, length and repetition of its class names. The author's treatment, admitted to look radical to newcomers, is to throw out everything without an obvious reason to exist: the classes go, the links are made relative to the site's root, and the optional quotation marks and closing tags are left out. The rule recalled is the old one for names, as long as necessary and as short as possible, and the reader is then invited to question whether the changes were fair.[3] The fifth turns to meaning. Its foreword advises choosing the right element for the job in place of generic containers, understanding the elements that mark the regions of a page and the hierarchy of headings, writing minimal HTML and leaving layout to CSS, and it describes accessibility attributes as able to make or break the experience of a page; the author summarises quality as using HTML for the right purpose, in the right way, with as little code as possible. The example that follows is a set of figures from an old municipal page, laid out with emphasis for a title and line breaks for rows, which the booklet calls a sign of thinking in terms of presentation. It is rewritten as a table with a caption and with header cells tied to their rows, and the author points out two decisions in the rewrite that could reasonably have gone the other way. The old page wrote its element names in capitals, which the booklet declines to condemn: that was the original style of the language, and nothing speaks against it.[5]

Idiosyncrasies of the HTML parser goes underneath all this, to the program that turns markup into the tree a browser works with and to its many strange behaviours, which it tests with quizzes that its description calls almost impossible.[22]

The quality and architecture of CSS

CSS Optimization Basics starts from the complexity of present web development, which it describes as a loss of focus: with so many options it is less clear what deserves attention. Optimisation matters, it argues, because quality matters, quality control being what separates professional from amateur work, and the beneficiary is the user. The book deliberately leaves out the preprocessors that generate CSS, on the reasoning that there is more lasting reward in knowing the underlying technology than in knowing an abstraction over it, and it follows a published style guide in its own code. Its contents divide the subject in two. Optimisation in everyday work covers understandability, consistency, the ordering of declarations and selectors, simplicity, naming and shorthand notation, with several popular concerns, the speed of selectors among them, expressly labelled irrelevant; optimisation for production covers what is done to the files before they are served. Automating all this is encouraged, the author says, but one must first know what to optimise for.[6] The three booklets collected in The Little Book of Little Books cover the neighbouring subjects of frameworks, coding guidelines and the checking of a site's quality; their author remarks that the first of them is an underrated treatment of its subject, admits that the third was not the best that could have been done, and expects to rewrite one or more of them.[7]

Enduring CSS is not about what goes inside the braces of a rule but about what lies outside them, the organisation of style sheets in large applications that change quickly, considerations which, it says, a small project can happily ignore.[21] The adjacent U&I with React (2017) takes up the same problem inside a component library, comparing the ways of styling components.[24]

Layout

The two layout systems are distinguished by dimension. The CSS Grid Guidebook explains that a grid lays out its boxes in rows and columns at once, and that flexible boxes are the tool when elements need arranging in one direction only; in each system a container element is declared and its children become the items that the container arranges, and in a grid an item can also be placed by the numbered lines between rows and columns.[10] CSS Flexbox goes through the properties of the container and of the items one value at a time, direction, wrapping, the distribution of spare space along and across the main axis, the growing and shrinking of items, and ends with recipes for the old difficulty of centring an element horizontally, vertically and both. It recommends practice over reading as the way out of what it calls tutorial hell.[9] The two picture books show the same properties as drawings,[16][17] and Flexbox Website builds the layout of a whole site.[23]

Animation and graphics

Creative transitions and animations in CSS is a collection of more than a hundred experiments, from transforms and transitions on buttons and images to larger animated projects, arranged so that each can be tried separately.[15] Drawing is otherwise the province of the vector language, which Fundamentals of HTML, SVG, CSS and JavaScript for Data Visualisation introduces as the means of describing the bars, lines, circles, axes and legends of a chart.[11]

Around the page

Markup is seldom written by hand alone, and several adjacent books show where it comes from. Taming Thymeleaf and Modern frontends with htmx (2025) are about producing HTML on the server and adding interactivity with little JavaScript.[18][25] Web Components (2020) describes the browser's own facilities for defining new elements.[26]

Checking that a page still looks right is the subject of Get Started with Visual Regression Testing and WebdriverIO (2017), adapted from a course delivered by email. It defines a regression as code that used to work and no longer does, so that existing features have to be examined after every update as well as new ones, and automated testing as code that performs a user's actions; automation, it says, takes over the boring and repetitive checks and cannot replace people, since someone must write and maintain it and since some things, an animation for instance, are very hard to verify by program.[14] Coding Challenges and Solutions - The Smartest Way to Learn Html and CSS serves a humbler kind of checking, of the learner: three sets of questions with answers, on the argument that practice teaches more than rereading. Reading a passage again, it says, adds little, and highlighting gives only the illusion of engagement, whereas ten minutes of reading followed by twenty of practice keeps a learner awake and honest about what has been learned.[13]

Questions about HTML and CSS

Which HTML and CSS book should I start with?

A complete beginner has Zero to Website, a long guide to building websites from nothing, and Intro to Software Development (2018), a free book that introduces the front end to readers who need only be confident users of a computer.[20][12] Coding Challenges and Solutions - The Smartest Way to Learn Html and CSS is a workbook of questions for beginners who want practice.[13] For layout, the quickest books are Visual CSS Flexbox and Visual CSS Grid, cheat sheets with one illustration for each value of each property.[16][17]

What is the difference between HTML and CSS?

HTML describes the content of a page, and CSS describes style, such as the weight, colour and size of type, and position.[11] The smallest unit of HTML is an element such as a paragraph, made of an opening tag, some content and a closing tag, and the browser decides how each element is styled unless told otherwise.[11]

Should I use flexbox or grid?

The CSS Grid Guidebook distinguishes the two by dimension: a grid lays out its boxes in rows and columns at once, and flexible boxes are the tool when elements need arranging in one direction only.[10] In each system a container element is declared and its children become the items that the container arranges.[10] CSS Flexbox ends with recipes for centring an element horizontally, vertically and both.[9]

Is it valid to leave out closing tags in HTML?

The standard allows some markup to be omitted, a method of economy that the Upgrade Your HTML series says almost nobody uses.[4] The foreword to Upgrade Your HTML IV argues that because the rules for reading HTML are well defined and implemented alike in browsers, there is no harm in omitting optional tags provided the result is checked with a validator.[4] A writer trained in the stricter syntax of an earlier decade, it adds, may at first find it uncomfortable.[4]

Is HTML easy to learn?

The author of Upgrade Your HTML holds that HTML only looks easy, and supports the claim with the number of elements in the language, which few developers could list, and with the habit of calling elements tags.[1] The last numbered recommendation from one standards body defined 111 elements.[1] The fifth book in the series summarises quality as using HTML for the right purpose, in the right way, with as little code as possible.[5]

How do I write better CSS?

CSS Optimization Basics divides the subject in two: optimisation in everyday work covers understandability, consistency, the ordering of declarations and selectors, simplicity, naming and shorthand notation, and optimisation for production covers what is done to the files before they are served.[6] Several popular concerns, the speed of selectors among them, are expressly labelled irrelevant.[6] The book leaves out the preprocessors that generate CSS, on the reasoning that there is more lasting reward in knowing the underlying technology than in knowing an abstraction over it.[6]

Sources

Every source is a Leanpub book. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.

  1. 1.
    Upgrade Your HTML, Jens Oliver Meiert: 10 Examples to Improve Your Markup Free sample: the introduction and the first example, on the title attribute. 2026. Free sample: PDF · EPUB
  2. 2.
    Upgrade Your HTML II, Jens Oliver Meiert: 10 More Examples to Improve Your Markup Free sample: the foreword, the introduction and the first example, on a sharing link. 2026. Free sample: PDF · EPUB
  3. 3.
    Upgrade Your HTML III, Jens Oliver Meiert: 10 More Examples to Improve Your Markup Free sample: the foreword, the introduction and the first example. 2026. Free sample: PDF · EPUB
  4. 4.
    Upgrade Your HTML IV, Jens Oliver Meiert: 10 More Examples to Improve Your Markup Free sample: the foreword, the introduction and the opening examples, on validation. 2026. Free sample: PDF · EPUB
  5. 5.
    Upgrade Your HTML V, Jens Oliver Meiert: New Examples to Optimize Your Markup Free sample: the foreword, the introduction and the first example, on a table. 2026. Free sample: PDF · EPUB
  6. 6.
    CSS Optimization Basics, Jens Oliver Meiert Free sample: the introduction, on why optimisation matters and what the book leaves out. 2026. Free sample: PDF · EPUB
  7. 7.
    The Little Book of Little Books, Jens Oliver Meiert: HTML and CSS Frameworks, Coding Guidelines, Quality Control Free sample: the introduction to the combined edition only. 2026. Free sample: PDF · EPUB
  8. 8.
    Rote Learning HTML & CSS, Jens Oliver Meiert Free sample: the introduction; the lists themselves are not in the sample. 2026. Free sample: PDF · EPUB
  9. 9.
    CSS Flexbox, CodeSweetly: Learn Flexbox with Live Examples Free sample: the contents, the introduction and the first properties. 2026. Free sample: PDF
  10. 10.
    The CSS Grid Guidebook, CodeSweetly: Understand the Grid Layout Module Free sample: the contents, the introduction and the opening on containers and items. 2026. Free sample: PDF
  11. 11.
    Fundamentals of HTML, SVG, CSS and JavaScript for Data Visualisation, Peter Cook Free sample: the introduction, the overview of the four languages and the chapter on HTML. 2025. Free sample: PDF · EPUB
  12. 12.
    Intro to Software Development, Iakiv Kramarenko Free sample: the contents, the foreword and the opening of the front-end part. 2018. Free sample: PDF
  13. 13.
    Coding Challenges and Solutions - The Smartest Way to Learn Html and CSS, Bolakale Aremu: Web Development from Beginner to Paid Professional Free sample: the introduction and the first set of questions. 2026. Free sample: PDF · EPUB
  14. 14.
    Get Started with Visual Regression Testing and WebdriverIO, Kevin Lamping, Micah Godbolt Free sample: the preface and the definitions of terms. 2017. Free sample: PDF · EPUB
  15. 15.
    Creative transitions and animations in CSS, Andrés Cruz Yoris: A practical guide to building smooth effects, advanced animations, and visual projects with HTML, CSS, and JavaScript The free sample is front matter and an index of the effects: from those and the description. 2026. Free sample: PDF
  16. 16.
    Visual CSS Flexbox, CodeSweetly: Learn CSS Flexbox Quickly with Images The free sample is two illustrations: from the description. 2026. Free sample: PDF
  17. 17.
    Visual CSS Grid, CodeSweetly: Learn CSS Grid Quickly with Images The free sample is two illustrations: from the description. 2026. Free sample: PDF
  18. 18.
    Taming Thymeleaf, Wim Deblauwe: Practical Guide to building a web application with Spring Boot and Thymeleaf The free sample was not used: from the description and table of contents. 2026. Free sample: PDF
  19. 19.
    The Web Development Glossary, Jens Oliver Meiert: More Than 2,000 Key Terms for Developers The free sample was not used: from the description. 2026. Free sample: PDF · EPUB
  20. 20.
    Zero to Website, Muhammad Ahsan Ayaz: A Beginner's Guide to Building for the Web No sample: from the description alone. 2026.
  21. 21.
    Enduring CSS, Ben Frain: Architect and maintain large-scale CSS codebases No sample: from the description and table of contents. 2016.
  22. 22.
    Idiosyncrasies of the HTML parser, Simon Pieters No sample: from the description and table of contents. 2026.
  23. 23.
    Flexbox Website, Makzan: Building Website Layout with FlexBox No sample: from the subtitle and table of contents; the description is empty. 2015.
  24. 24.
    U&I with React, Farhad Ghayour: On building U&I components with React No sample: from the description and table of contents. 2017.
  25. 25.
    Modern frontends with htmx, Wim Deblauwe: Use htmx with Spring Boot and Thymeleaf to build dynamic and interactive web application No sample: from the description and table of contents. 2025.
  26. 26.
    Web Components, Joerg Krause: The future of modern Web Apps No sample: from the description and table of contents. 2020.

Further reading

Other books in the library on neighbouring ground, not cited above.

This is an article created from the free samples of 14 Leanpub books and the descriptions and tables of contents of 12 more. We're building these articles to provide you, the Leanpub reader, with a good jumping-off point to discover more Leanpub books that are interesting and relevant to you. We never use material which is paid-only when building these articles: we only use material which is already free on Leanpub. However, Leanpub authors can opt out from inclusion in articles from their book settings page.

Updated November 2026.

In the Leanpub store: 162 books · 6 courses in the HTML category · also filed under CSS, Web Accessibility

All topics