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

CSS How to Make a Website CSS: Cascading Style Sheets Use ID Selectors

Natalia P.
Natalia P.
353 Points

Why change text color in css rather than in html?

Earlier in the lessons the instructor went over changing the color of the header. He did it strictly for practice and after going over it removed it from the project. Why are we now doing the same thing using css instead? I understand that css is for modying style and html for content but is there ever a time when styling via html is useful? Or is it impossible once you add the css stylesheet attribute to the html?

Natalia P.
Natalia P.
353 Points

Never mind. I reviewed that video (it was the 2nd or third) and he did specify that we were typing css code. What confused me is that we did not have any css stylesheet attribute tagged to the workspace. I take it that we don't have to have a css stylesheet tagged in order to change a style value like he said, but it is only required if you want to normalize the browser style settings. It would have made more sense if he had started writing in css at this point in the lessons instead of back then when we were predominantly going over html. If anyone has some thoughts please share, thanks.

3 Answers

Hi,

All the above, and i think if you watch a video , yes everyone are different learners but what it helps me is to watch him doing it and explaining and when he finished the sentence, i pause and write the code so next 5 sec me writing code i wont miss what he was talking and i will be sure that i have 100% focus on him, on learning.

Also you could put style tags and do it there at the top , if its just one page forever i guess. it will reduce the files you send in the internet .

In CSS you control everything in every page fast and smooth . You target the code you want to change properties of it and you write it in CSS. Everypage that the CSS is applied will look the same. If you make any changes to a nav bar, it will apply to every page. its easier than going over hundreds of html file and paste the exactl code. It will waste time and get messy . The best practice is to do it on other file like its done.

When you will learn , if you will choose to learn server language e.g. PHP there you will learn how to use the same code in just a smiple word .

So you put all your header and footer into a folder and you give it a name then with php you will bring it back to every page and plus it will be cleaner for you to work in the code .

A bit detailed on how this can look in the future too if it made any sense . I hope it helps.

Natalia P.
Natalia P.
353 Points

Thanks, I appreciate that you answered my curiosity about where I am headed.

Jeremy Hayden
Jeremy Hayden
1,740 Points

You used to be able to change text color directly in html and not have to use css.

However much of that has been depreciated with html5. Now it is recommended to use css.

That said, you do not have to put css on its own file. You can include it directly on your html page.

Since this was a beginning video, the instructor at first put the css right into the html page to demonstrate what exactly he was modifying.

After the students are comfortable with the concept of css and how it works, then the instructor shows that the code can be divided into separate files to make it easier to work with.

In fact any code can be broken up into smaller files if you want.

For example, some people will put the headers and footers in their own files.

Natalia P.
Natalia P.
353 Points

Cool thank you Jeremey! What is "CD's"?

Jeremy Hayden
Jeremy Hayden
1,740 Points

Lol, good catch. CDs is iphone autocorrect for css. I fixed the post. Thank you