HTML Introduction to HTML and CSS Make It Beautiful With CSS Test: Styling by Element and Class

Rama Faris
Rama Faris
344 Points

How i set the color on border by css

Would you please explain to me how we use border at css

index.html
<!doctype html>
<html>
  <head>
    <link href="styles.css" rel="stylesheet">
  </head>
  <body>

    <p class="main-pg">My amazing website</p>

  </body>
</html>
styles.css
.main-pg{
  p{
  border wide:4px;
  border solid :red;
}
}

1 Answer

Hey Rama,

In CSS when you declare the class name it will automatically affect the element with that class name. So you dont need the p {} in your example. You also only need a colon after your property declaration. It would looks like this.

.main-pg {
  border: solid red 4px;
}

All of the border properties can be applied in a single declaration here, and you only need 4px to declare the width not 4px wide.

Hope this helps

Dylan