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
Percy Vasquez
Courses Plus Student 1,339 PointsHow to manage the style for many pages of a website in one external style sheet
Hello people, I wondered if this is possible. To Manage the style for many pages of your website in one external cascading style sheet. I happen to have a project for school, and I want to do that. So, if yes, can someone please help me in how to put them in sections or whatever is the process for that? Thank you very much for the one who will help me. Really appreciate it.
3 Answers
Erik Montes
3,717 PointsYou can use unique ID's for each page. Then you can use that as the selector to style that particular page.
page1.html
<html>
<head>
</head>
<body id="page1">
<h1>Page 1!</h1>
</body>
</html>
page2.html
<html>
<head>
</head>
<body id="page2">
<h1>Page 2!</h1>
</body>
</html>
Then in your external stylesheet you can do something like this:
h1 {
font-weight: bold;
}
#page1 h1 {
color: red;
}
#page2 h1 {
color: green;
}
In my example above, h1's in both pages will be bold, however in page 1 it'll be red and in page 2 it'll be green. Tada!
Percy Vasquez
Courses Plus Student 1,339 PointsCool man. Thank you.
Percy Vasquez
Courses Plus Student 1,339 PointsAnother question. How did you do to insert those pictures in this comment? I really would like to know
Erik Montes
3,717 PointsThey're not pictures, just syntax highlighting. When you type in the comment box just add 4 spaces at the beginning of each line of code.
<--4 spaces
<--another 4 spaces