Fork me on GitHub

Cascading Style Sheets (CSS)

Cascading Style Sheet (CSS) files contain rules for how to display and lay out the HTML content when it is rendered by a web browser.

Why is CSS necessary?

CSS separates content contained in the HTML file from how the content should be displayed. That separation between content and how to display it enables devices to render the content differently based on factors such as screen size. For example, a mobile device does not have as much space to display a navigation bar on the side of a page so it is often pushed down below the main content. The Bootstrap Blog example shows that scenario when you resize the browser width.

How is CSS retrieved from the web server?

The HTML file sent by the web server contains a reference to the CSS file(s) needed to render the content. The web browser requests the CSS file after the HTML file as shown below in a screenshot captured of the Chrome Web Developer Tools network traffic.

Google Chrome Web Developer Tools shows how CSS is separate from the HTML content.

That request for the fsp.css file is made because the HTML file for Full Stack Python contains a reference to theme/css/fsp.css which is shown in the view source screenshot below.

View source screenshot for the fsp.css file in index.html.

Responsive design

Responsive design is an approach for creating CSS that lays out content differently based on screen attributes. The responsiveness is accomplished by implementing media queries in the CSS.

CSS preprocessors

CSS frameworks

CSS frameworks provide structure and a boilerplate base for building a web application's design.

Design resources

  • The Bootstrapping Design book is one of the clearest and concise resources for learning design that I've ever read. Highly recommended especially if you feel you have no design skills but need to learn them.

  • Kuler is a complementary color picker by Adobe that helps choose colors for your designs.

CSS resources

Once your app is styled what do you need to learn next?

How do I create a better browser experience with JavaScript?

How should I host my static content such as my CSS files?

How do I save and version my code so it doesn't get lost?


Interested in a complete Full Stack Python book with detailed tutorials and example code? Sign up here and you'll get an alert email if a book is created. No other emails will be sent other than sign up confirmation.