Styles in the Document
The second way to write CSS code is by writing styles in the style
element in the HTML header (the head
element).
<head>
<style>
p {
background-color: purple;
}
</style>
</head>
This code sets the background color of every p
element to purple.
To apply multiple styles, we can write another style after the semicolon (;) in a similar way:
<head>
<style>
p {
background-color: purple;
text-align: right;
}
</style>
</head>
This sets all p
elements to have purple background and right-aligned text.
Instructions
Add a style
element inside the head
element.
Add a green background color to each p
element.
Start programming for free
3/5