© Mark J. Collins 2017

Mark J.  Collins, Pro HTML5 with CSS, JavaScript, and Multimedia, 10.1007/978-1-4842-2463-2_19

19. Dynamic Styling

Mark J. Collins

(1)Chesterfield, Virginia, USA

In the previous chapter, I explained how you can dynamically change the HTML content using JavaScript. There are methods available to create new DOM elements as well as to rearrange or modify the existing elements. Similar capability exists for modifying the styling of those elements. In this chapter, I will describe four techniques that you can use to dynamically change the style rules using JavaScript:

  • replacing style sheets

  • changing the style rules

  • modifying the CSS classes

  • adjusting inline styles

These scenarios provide increasingly finer control of the styles applied ...

Get Pro HTML5 with CSS, JavaScript, and Multimedia: Complete Website Development and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.