Skip to Main Content
JavaScript Absolute Beginner's Guide, 2nd Edition
book

JavaScript Absolute Beginner's Guide, 2nd Edition

by Kirupa Chinnathambi
December 2019
Beginner content levelBeginner
464 pages
10h 31m
English
Que
Content preview from JavaScript Absolute Beginner's Guide, 2nd Edition

27. Styling our Content

In This Chapter

  • Learn how to change CSS using JavaScript

  • Understand the pros and cons of setting styles directly as opposed to adjusting class values

  • Use classList to make fiddling with element class values a breeze

In the previous chapter, we looked at how to modify our DOM’s content using JavaScript. The other part of what makes our HTML elements stand out is their appearance, their styling. When it comes to styling some content, the most common way is by creating a style rule and have its selector target an element or elements. A style rule would look as follows:

.batman {
  width: 100px;
  height: 100px;
  background-color: #333;
}

An element that would be affected by this style rule ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript Absolute Beginner’s Guide

JavaScript Absolute Beginner’s Guide

Kirupa Chinnathambi

Publisher Resources

ISBN: 9780136204213