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

JavaScript

Why learn to adjust colors and styling features with Javascript rather than HTML or CSS?

Currently on the Javascript & The Dom lessons.

Throughout the course you manipulate the colors of texts by changing them through .getElementById. Why not just change this through CSS or even HTML? Is this a better practice?

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

There isn't necessarily a need to do this in practice. This is just to demonstrate what can be done to properties with JavaScript and to get you thinking about what you can and should be doing with the DOM. Later on for example you'll be using the value property to change the text content of elements.

There's lots more fun things on the way :)

Ah, I see. Thanks for the input!