Cascading Style Sheets, fondly referred to as CSS, is a style sheet language used to define visual appearance and formatting of HTML documents. WordPress themes use CSS and HTML to output the data generated by WordPress. Every WordPress theme contains a style.css file that has style rules to define the formatting of pages generated by WordPress.
Before CSS was released, there was only HTML and JavaScript. Developers would have to sit and style each individual element, which happens to be not only tedious but also a cumbersome process. Today, with the help of CSS, enterprise-level websites can be stylized in a matter of hours. This is due to the cascading nature of CSS.
CSS handles the look and feel part of a web page. Using CSS, you can control the color of the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, what background images or colors are used, layout designs, variations in display for different devices and screen sizes as well as a variety of other effects.

Advantages of CSS
CSS saves time
- You can write CSS once and then reuse the same sheet in multiple HTML pages. You can define a style for each HTML element and apply it to as many Web pages as you want.
Pages load faster
- If you are using CSS, you do not need to write HTML tag attributes every time. Just write one CSS rule of a tag and apply it to all the occurrences of that tag. So less code means faster download times.
Easy maintenance
- To make a global change, simply change the style, and all elements in all the web pages will be updated automatically.
Superior styles to HTML
- CSS has a much wider array of attributes than HTML, so you can give a far better look to your HTML page in comparison to HTML attributes.
Multiple Device Compatibility
- Style sheets allow content to be optimized for more than one type of device. By using the same HTML document, different versions of a website can be presented for handheld devices such as PDAs and cell phones or for printing.
Global web standards
- Now HTML attributes are being deprecated and it is being recommended to use CSS. So it’s a good idea to start using CSS in all the HTML pages to make them compatible with future browsers.
CSS Cascade
A very important piece of CSS is the “Cascading” part. The browser reads style definitions from top to bottom in a style sheet. This means that a style you define lower in the style sheet will override any previous styles defined earlier in the style sheet.
The major ways CSS cascade
- Elements – The same CSS style can be applied to multiple elements to achieve the same style.
- Multiple Style One Element – Multiple styles can be applied to a particular HTML element to achieve a unique style.
- Same style, Multiple Pages – The same stylesheet can be applied to different HTML pages altogether to achieve a template styling very quickly.
Selectors
- Universal selector: Selects all elements. Optionally, it may be restricted to a specific namespace or to all namespaces. Syntax: * ns|* *|*
- Type selector: Selects all elements that have the given node name. Syntax: elementname
- Class selector: Selects all elements that have the given class attribute. Syntax: .classname
- ID selector: Selects an element based on the value of its id attribute. There should be only one element with a given ID in a document. Syntax: #idname
- Attribute selector: Selects all elements that have the given attribute. Syntax: [attr] [attr=value] [attr~=value] [attr|=value] [attr^=value] [attr$=value] [attr*=value]
Grouping selectors
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <style> h1{ color:green; } h3{font-style: italic; font-family: fantasy;} ul{background-color: cornflowerblue; width: 20%; padding: 1% 2%; border-radius: 50px;} h2{text-decoration: line-through red;} p{font-style: italic;} </style> </head> <body > <h1>____'s blog</h1> <h3>Contents</h3> <ul> <li>First post!</li> </ul> <h2>First Post</h2> <p>Posted on some date in some year</p> </body> </html>
Output :

Some of the important CSS properties
Display
- block
- inline
- inline-block
- none
Height and width
- Px
- Em
- Rem
- %
- auto
Margin and padding
- Margin and padding are the two most commonly used properties for spacing-out elements. A margin is a space outside something, whereas padding is the space inside something.
Border
- border-width
- border-style
- border-color
Floats
- Float is a property that forces any element to float (right, left, none, inherit) inside its parent body with the rest of the element to wrap around it. This property can be used to place an image or an element inside its container and other inline elements will wrap around
- left
- right
- none
Color
- Color here refers to the text color. It takes on a #hex value or an RGB value as with border colors.
Background
- The background property is a shorthand property for
- background-color
- background-image
- background-position
- background-size
- background-repeat
- background-origin
- background-clip
- background-attachment
Font
- The font property is a shorthand property for
- font-style
- font-variant
- font-weight
- font-size
- line-height
- font-family