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

Not sure which language to use

Hello Community,

I have a question regarding a language needed to shape my idea. I am just familiar with CSS and HTML, so I am a bit lost. Let me explain this.

I'd like to be able to hover over one element (text) and change permanently its state affecting the page background as well. When hovering hover other elements, I'd like to make the previous elements change back to normal.

For instance. Let's imagine one page with two words next to each other. Yellow and Blue. The background is white and the words are black in a normal state.

1) I hover over the <h1>blue</h1>, and the text + page background turn from white and black to two shades of blue (just to create separation between text and background). 2) Then, I hover over the <h1>yellow</h1> and the text + page background turn and stay yellow. At the same time, the <h1>blue</h1> goes back to black.

I feel I need something with variables, which allows me to change the state of multiple elements together permanently, but not sure how to achieve this.

Thanks for your support!

1 Answer

Steven Parker
Steven Parker
231,248 Points

Just as HTML generally controls the structure of a web page, and CSS controls the styling, the language that controls the behavior of a web page is JavaScript. These three together are the essence of front-end development.

The job you have in mind is relatively easy to accomplish in JavaScript, which is my recommendation for your implementation.

Thanks Steven! I will explore Javascript next!