From the course: CSS for Developers

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Manipulating CSS with JS

Manipulating CSS with JS - CSS Tutorial

From the course: CSS for Developers

Manipulating CSS with JS

- [Instructor] We can use JavaScript to modify the DOM, CSSOM or both to create dynamic web applications. When we modify CSS with JavaScript, we are literally working with CSS properties as actual properties living in a JavaScript object. If you've been working with a language like JavaScript, this makes the transition to working with CSS a little easier because it offers a representation of what CSS really is. An object model of style properties applied to elements. Let me show you an example of what I mean. So, for this example, I'm going to use the document styleSheets property, which returns a list of every style sheet that's applied to any page. If I head over to the Exercise File for this lesson, I've got my HTML file here, and I just want to show you that I've got two style sheets loading in this page, base-style.css and style.css. Let's go ahead and view this in the browser. I'll right-click, we'll say Inspect, and we've been hanging out here in Elements, but let's go to…

Contents