Here is some CSS I’m using for a personal portfolio, I have eight items that require a background url and size. Since tis css follows a very simple formula I was wondering if a bit of JavaScript could eliminate the need for me create a new CSS selector every time I add a portfolio piece. Is it possible to simply modify the HTML <article id="item22"></article> and have JavaScript create the corresponding selector in CSS?
Hi @CooKachoo, you mean you want to dynamically generate CSS rules for each element? This can be done by creating a style element (or query an existing one), and using insertRule() like so: