CSS stands for Cascading Style Sheets. It consists of the properties that style webpage code (usually HTML). It is not a programming or markup language, but rather a stylesheet language. We use this to specifically style certain areas of the web page’s content. It can also be used to style React components.
The following illustration shows how we declare a CSS property. The structure is called a ruleset.
A ruleset has the following attributes:
This specifies the part of HTML code that will be styled by the ruleset. It uses the class name or tag from HTML (e.g. <p>
) to specify the CSS styling.
This part specifies the styling properties. You can style the font, color, or alignment of the text here.
This part of the declaration specifies which characteristic will be styled.
This part specifies how the property will be styled.
- The ruleset must be enclosed with curly brackets,
{}
- Each statement in the ruleset must be terminated with a semi-colon
If multiple elements require the same styling, they can all be declared as selectors. The following snippet shows how this may be done:
p, h1 {
font-family: "Times New Roman";
}
There are three ways to use CSS styling:
style
attribute.head
section of the HTML code.Free Resources