Practice NOW!
Solve the exercises below this HTML file. Feel free to search online for answers! This is what a programmer does!
Exercise 1: Tag Selector
- Apply a style to the
<body>
element, setting the background color to light gray. Hint: Change thebackground-color
property.
Exercise 2: Class Selector
- Style the elements with the class “header” to have a blue color and be centered. Hint: Change the
color
andtext-align
properties.
Exercise 3: ID Selector
- Add an underline and change the color to green for the element with the ID “special-link”. Hint: Change the
text-decoration
andcolor
properties.
Exercise 4: Descendant Selector
- Make the text inside the
<ul>
elements bold. Hint: Change thefont-weight
property.
Exercise 5: Child Selector
- Style only the direct children of the
<ul>
by giving them a border. Hint: Add aborder
property to the direct children of theul
.
Exercise 6: Attribute Selector
- Target the
<a>
element with an attribute selector and give it a red color. Hint: Change thecolor
property.
Exercise 7: Pseudo-Class Selector
- Style the link so that it changes color when hovered over. Hint: Change the
color
property.
Exercise 8: Pseudo-Element Selector
- Apply italic style to the first line of the paragraph inside the container. Hint: Change the
font-style
property.
Exercise 9: Grouping Selector
- Group the
<h1>
and<h2>
elements and give them a common style. hint: Change thefont-style
property.
Exercise 10: Universal Selector
- Apply a margin to all elements on the page. Hint: Add a common property, such as
margin
.
Here is the solution. Please do not open if you haven’t tried to solve it yourself!