JavaScript CSS Selectors Quickstart CSS Selector Basics Attribute Selectors Challenge

Create an attribute selector that targets an img element with a title attribute value of "avatar". Give the element

Create an attribute selector that targets an img element with a title attribute value of "avatar". Give the element a border radius of 50%.

style.css
/* Complete the challenge by writing CSS below */
index.html
<!DOCTYPE html>
<html>
<head>
    <title>Attribute Selectors</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="page.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
    <div id="container">
        <form class="form-contact">
        <img src="avatar.png" title="avatar" alt="user">

          <label for="un">Username:</label> 
          <input type="text" id="un">

        <label for="pw">Password:</label>
            <input type="password" id="pw">

          <input type="submit" value="Sign up">
            <input type="reset" value="Reset">
        </form>
    </div>
</body>
</html>

1 Answer

This page from the course gives you an example:

You may also include the attribute value in the selector to make it even more specific. For instance, match only a div element whose title value is Tooltip:

div[title="Tooltip"] {
  border: 1px solid lemonchiffon;
}