In this “CSS How To Tutorial”, you will learn the syntax and rules of the Cascading Style Sheet (CSS) language. You will learn the components of CSS rules, including selectors, declarations, properties, and values. You will learn how to style a series of simple HTML elements. You will also learn how to use shorthand properties.
Setting Up the HTML Code
The HTML code for this How To Tutorial will have three main elements the <h1>, <h2> and <p> tags.
<h2> CSS Heading Two</h2>
<p> Some text about your css tutorial would go here</p>
Creating a Rule Set
A css rule or css rule set, is a statement that tells a browser how to render the elements on an HTML page. A css rule set consists of a selector followed by a declaration block. Inside the declaration block, there can be one or more declarations. Each declaration contains a property and a value.
| selector | Declaration block | |||
| declaration | declaration | |||
| Property | Value | Property | Value | |
| .body | {color: | Red; | padding: | 5px;} |
The first step in creating a rule set is to decide on a css selector. The selector “selects” the elements on an HTML page that are affected by the css rule set. The selector consists of everything up to the first left curly bracket.
The selectors for this CSS How To Tutorial or H1, H2, and P
The declaration block is the container that consists of everything between (including) the curly brackets. Inside the declaration block, there are one or more declarations. Declarations tell a browser how to draw any element on a page that is selected. A declaration consists of a property and one or more values, separated by a colon. The end of each declaration is indicated with a semicolon.
Setting Up the CSS Code
<!–
h1 {text-align: center; }
h2 {font-style: italic; }
p {color: maroon;}
–>
</style>
The property is an aspect of the element that you are choosing to style. There can be only one property within each declaration unless a shorthand property is used.
The value is the exact style you want to set for the property. Values can include length, percentage, color, url, keyword, and shape.
The first rule set will target the <h1> element and align it to the center of the browser window.
The second rule set will target the <h2> element and render it in italics.
The third selector will target the <p> element color all the text found inside the element maroon.
Helpful Articles
Trying to Lose Weight, Go Out With Friend And Family And Not Offend
This may sound amazing, but one of the hardest things to do when you are losing weight is to get the help of friends and family...
Top 10 Weight Loss Myths
Have you sometimes felt confused about weight loss and nutrition guides that should help you take the right decisions about your health, yet for some reason they don’t? Here are some of the most frequent weight loss theories, and their rebuttals...
How Do I Get Out Of A Weight Loss Plateau, Problem And Solution No. 2
When you ask the question “how do I get our of a weight loss plateau?” there can be more than one answer, depending on what the reason for the problem is...