What is CSS: What are Cascading Style Sheets?

Additionally, cascading can help create themed designs, which help designers fine-tune aspects of a design without compromising the overall layout. Before CSS, nearly all presentational attributes of HTML documents were contained within the HTML markup. All font colors, background styles, element alignments, borders, and sizes had to be explicitly described, often repeatedly, within the HTML.

what are cascading style sheets

Print designers have long used style sheets to ensure that their designs are printed exactly to their specifications. A style sheet for a web page serves the same purpose, but with the added functionality of also telling the web browser how to render the document being viewed. Today, CSS style sheets can also use media queries to change the way a page looks for different devices and screen sizes. This is incredibly important since it allows a single HTML document to be rendered differently according to the screen being used to access it. One of the goals of CSS is to allow users greater control over presentation.

The Cascade Example

The creative ability in programming is allowing people to do even more with their ideas. If you want to advance your career,  take the first steps by learning to code. Having these skills can help you open doors to those new professional possibilities. Enroll in Udacity’s Intro to Programming Nanodegree today to start the journey.

The CSS font-size property defines the text size to be used. CSS is compatible with the older language versions so that we can use CSS with the earlier language versions. CSS allows the content to be optimized for more than one type of device. If we require a global change in the file, it can be simply done by changing the style by which all the elements on the web page will update automatically. The CSS file provides a flexible look to the website, which can be altered in a convenient way.

CSS Border

We round off the module by looking at applying custom fonts to your page, and styling lists and links. This will help to demonstrate just how the cascading style is taken in by the HTML document. Notice that a font-family property was also added in the second set. This is where your unlimited style potential is set for use.

what are cascading style sheets

User-agents, or browsers, have basic style sheets that give default styles to any document. Most browsers use actual stylesheets for this purpose, while others simulate them in code. We website development css cascading figured that if we could reduce the size of style sheets, we could enable designers to write and edit style sheets “by hand.” Also, short style sheets load faster than longer ones.

Tools for CSS development

Where HTML provides the bones or structure to a document, CSS injects the style for it. CSS allows you to manipulate HTML elements in various ways such as size, shapes, colors, or even interactions from the end-users. Think of CSS as a toolbox that you can reference when trying to fine-tune the website appearance to your needs. Cascade is the really special part of the term “cascading style sheet”. A web style sheet is intended to cascade through a series of styles in that sheet, like a river over a waterfall. The water in the river hits all the rocks in the waterfall, but only the ones at the bottom affect exactly where the water will flow.

  • Enroll in Udacity’s Intro to Programming Nanodegree today to start the journey.
  • We’ll look at this process more in the lesson How CSS works.
  • The modular nature of CSS means that styles can be reused in different parts of a site or even across sites, promoting consistency and efficiency.
  • Also, you can pretty much
    trust that most browsers will display the content of an h1 element using a big font size…

The declaration block contains one or more declarations separated by semicolons. CSS stands for Cascading Style Sheets language and is used to stylize elements written in a markup language such as HTML. It separates the content from the visual representation of the site. The relation between HTML and CSS is strongly tied together since HTML is the very foundation of a site and CSS is all of the aesthetics of an entire website. CSS was first developed in 1997 as a way for web developers to define the visual appearance of the web pages that they were creating.


In the sample code image below you have a very basic HTML document with no CSS work applied. Now that you have an answer to “what is CSS”, you might be curious as to the mention of cascading. The cascading term is used due to the way design values are read from the sheet.

The browser support status is shown on every MDN CSS property page in a table named “Browser compatibility”. Consult the information in that table to check if the property can be used on your website. For an example, see the browser compatibility table for the CSS font-family property. CSS (Cascading Style Sheets) allows you to create great-looking web pages, but how does it work under the hood? This article explains what CSS is with a simple syntax example and also covers some key terms about the language.

Internal or Embedded CSS:

Using CSS, you can control exactly how HTML elements look in the browser, presenting your markup using whatever design you like. Rather than by laboriously going through the document and changing the color for each individual h1 element. Pseudo-classes are used in CSS selectors to permit formatting based on information that is not contained in the document tree. In CSS, selectors declare which part of the markup a style applies to by matching tags and attributes in the markup itself.

what are cascading style sheets

Because CSS can cascade and combine, and considering how different browsers can interpret and implement the directives differently, CSS can be more difficult to learn than plain HTML. CSS also changes in browsers in a way that HTML really does not. Once you start using CSS, however, you’ll see that harnessing the power of style sheets will give you unbelievable flexibility in how you layout web pages and define their look and feel.

Browsers and CSS

For example, you could take a look at the MDN reference to the Backgrounds and Borders module to find out what its purpose is and the properties and features it contains. In that module, you will also find a link to Specifications that defines the technology (also see the section below). A document is usually a text file structured using a markup language — HTML is the most common markup language, but you may also come across other markup languages such as SVG or XML. This further decouples the styling from the HTML document and makes it possible to restyle multiple documents by simply editing a shared external CSS file. For example, headings (h1 elements), sub-headings (h2), sub-sub-headings (h3), etc., are defined structurally using HTML.

what are cascading style sheets