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-colorproperty.
Exercise 2: Class Selector
- Style the elements with the class “header” to have a blue color and be centered. Hint: Change the
colorandtext-alignproperties.
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-decorationandcolorproperties.
Exercise 4: Descendant Selector
- Make the text inside the
<ul>elements bold. Hint: Change thefont-weightproperty.
Exercise 5: Child Selector
- Style only the direct children of the
<ul>by giving them a border. Hint: Add aborderproperty 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 thecolorproperty.
Exercise 7: Pseudo-Class Selector
- Style the link so that it changes color when hovered over. Hint: Change the
colorproperty.
Exercise 8: Pseudo-Element Selector
- Apply italic style to the first line of the paragraph inside the container. Hint: Change the
font-styleproperty.
Exercise 9: Grouping Selector
- Group the
<h1>and<h2>elements and give them a common style. hint: Change thefont-styleproperty.
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!