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 JavaScript and the DOM (Retiring) Responding to User Interaction Listening for Events with addEventListener()

Why not CSS?

I'm just wondering if this specific solution to a problem (to capitalize the letters on hover) was just for practice and understanding or is it common to actually use JavaScript for for this?

Because all I had to do in CSS was to write: li:hover { text-transform: uppercase; }

to get the exact same effect, including with new list items. So if it actually is preferable to use JS for this, can someone tell me what the benefit is? Thanks in advance!

1 Answer

Steven Parker
Steven Parker
229,788 Points

Since you're taking a JavaScript course, I think it's safe to assume that most exercises will be primarily to illustrate how the mechanisms operate and not necessarily the best way to perform a specific function.

When possible, CSS-based solutions will often be more efficient and/or browser compatible than those using JavaScript. But there are also many things that can be done only using JavaScript.