curriculum/challenges/english/blocks/applied-visual-design/587d781d367417b2b2512ac8.md
This challenge will touch on the usage of pseudo-classes. A pseudo-class is a keyword that can be added to selectors, in order to select a specific state of the element.
For example, the styling of an anchor tag can be changed for its hover state using the :hover pseudo-class selector. Here's the CSS to change the color of the anchor tag to red during its hover state:
a:hover {
color: red;
}
The code editor has a CSS rule to style all a tags black. Add a rule so that when the user hovers over the a tag, the color is blue.
The anchor tag color should remain black, only add CSS rules for the :hover state.
const anchorElement = document.querySelector("a");
const anchorStyle = window.getComputedStyle(anchorElement);
assert.equal(anchorStyle?.color, 'rgb(0, 0, 0)');
The anchor tag should have a color of blue on hover.
assert.match(code,
/a:hover\s*?{\s*?color:\s*?(blue|rgba\(\s*?0\s*?,\s*?0\s*?,\s*?255\s*?,\s*?1\s*?\)|#00F|rgb\(\s*?0\s*?,\s*?0\s*?,\s*?255\s*?\))\s*?;\s*?}/gi
);
<style>
a {
color: #000;
}
</style>
<a href="https://freecatphotoapp.com/" target="_blank">CatPhotoApp</a>
<style>
a {
color: #000;
}
a:hover {
color: rgba(0,0,255,1);
}
</style>
<a href="https://freecatphotoapp.com/" target="_blank">CatPhotoApp</a>