Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML Introduction to HTML and CSS 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!