CSS Treehouse Club: CSS My First Web Page Comments, Selectors, and Syntax

Oscar Lopez
Oscar Lopez
971 Points

In Joy's CSS coding page, "style.css," why does she have "max-width: 900px;" twice in the body section?

i have tried it with only one of them and compared it to both of them together and I do not notice a difference.

Harry James
Harry James
14,078 Points

Hey there Oscar!

Where in the video does it say this? I'll have a look for you :)

2 Answers

Harry James
Harry James
14,078 Points

Hey again Oscar,

It must be a mistake in one of the workshop creation for one of the videos in that case, as the workspace for the current video does not have this issue.

Anyhow, like you've stated - by rewriting something twice within the same selector, it will make no difference as due to CSS's cascading nature, it will always pick the last value for the repeated property, and if this is the same as the first value, it will make no difference.

To explain,

samevalue.css
body {
  background-color: red;
  background-color: red;
  /* We'll ignore the first time we set this property, and only use the second. */
}
differentvalue.css
body {
  background-color: red;
  background-color: yellow;
  /* The background color will be yellow as due to the cascading nature, 
the last value for the repeated property is the value that will be used. */

Hopefully this should improve your understanding for this, but if there's anything you don't quite get, give me a shout :)

Oscar Lopez
Oscar Lopez
971 Points

I understand, thank you!

Oscar Lopez
Oscar Lopez
971 Points

It doesnt have it in the video. Thats odd, it did have it in the workspace. Im assuming its only suppose to be one