CSS formatting
We're now ready to put in our CSS, so how's the formatting in CSS?
CSS is pretty simple to understand:
- The selector: This is where you choose which HTML elements you want to add style to. In this example, we select all the
<h1>
elements. - Curly bracket: All styles inside these will apply to the HTML elements chosen by the selector
- Property: A property controls one aspect of an HTML element's style, such as text-align, color, width, background, and so on.
- Value: The value goes to the property. In this case, the text-align value could be left, right, center, or justify.
- Semicolon: It is mandatory to apply it at the end of a property.
You can have multiple styles in the same <style>
tag. Let's center all the h1
and p
tags.
You should have the following:
<style> h1 { text-align: center; } p { text-align: center; } </style>