Inline Styles
Now it’s your turn to write CSS. We’ve put the page back the way it was, without the stylesheet. There are three ways to add CSS to a page, and in this lesson, you’ll try all of them.
The first way is to write the styles directly in an element, in its style attribute. These are called inline styles:
<p style="color: orange">Learning CSS!</p>This paragraph will look like this:
Learning CSS!
The text color: orange is a declaration. It has two parts, separated by a colon:
- the property says what you want to change, here
color, the color of the text, - the value says what to change it to, here
orange.
CSS knows the names of many colors, such as red, blue, green or orange. You’ll learn the other ways to write colors in the lesson on colors.
To write more declarations, separate them with semicolons:
<p style="color: orange; text-align: center">Learning CSS!</p>Learning CSS!
The text-align property aligns the text, here to the center.
Instructions
- 1
Using the
styleattribute, make the main headingh1blue: give it the declarationcolor: blue. - 2
In the same
styleattribute, add a second declaration,text-align: center, to center the heading.