Skip to main content

The PreTeXt Guide

Chapter 49 Styling with CSS and SCSS

The PreTeXt conversion to HTML deliberately produces plain, semantic markup and leaves nearly all of the visual presentation to CSS (see Section 29.6 for the publisher-facing view). This allows the same content to be styled in many different ways, and for new themes to be added without changing the conversion. It also allows the styling to be shared across different output formats, such as web and print.
To work well in this system, HTML generated by XSL or Javascript should avoid hard-coded inline styles attributes and instead use classes and CSS to control the styling.
Every HTML book loads a single theme.css file, which is not written by hand but built from SCSS source by a small node script. This chapter is a map of that source, so you can find your way around to adjust an existing theme or contribute a new one. You do not need to be a web developer; a working knowledge of CSS and a willingness to read existing files is enough.