Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Annika Song
Annika Song
2,033 Points

how can i change the border style to solid and how can i change the border color to red?

thankyou

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{
border-width=4px;
border-style=
border-color= 
}
Matthew Lawson
Matthew Lawson
7,283 Points
.main-pg {
border-width: 4px;
border-style: solid;
border-color: red;
}

Make sure you use the colon after your CSS properties :)

Also if you're ever struggling with what certain properties you can use for various selectors you can always check the MDN or W3Schools.

https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_boxes/Borders

https://www.w3schools.com/cssref/default.asp

Hope this helps

2 Answers

Matthew Lawson
Matthew Lawson
7,283 Points

Jon Myzzle Absolutely! Learning the 'short-hand' I guess you could call it definitely simplifies things especially when you're working on bigger projects.

Jon Myzzle
Jon Myzzle
6,279 Points

Hello Annika,

There's a few ways you can do this but I find the easiest way, and simplest to remember is the following:

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

This code translates to exactly what you read. "I want my main-pg class to have a border that is 4px, its solid, and the color is red".

A great tool for referencing syntax in code is definitely the MDN website that Treehouse references quite a bit. If you find yourself stuck and cant remember the property, or even the correct format for the values, this site can help QUITE a bit!

I hope this helps!!

Cheers, and happy coding! :beers:

-Jon

Matthew Lawson
Matthew Lawson
7,283 Points

Jon Myzzle - an even better way of doing it! ?

Jon Myzzle
Jon Myzzle
6,279 Points

Indeed! It helps to keep the code consolidated and much much easier to read. Plus its easier to remember 1 line of properties /values versus remembering the 3 of them!