<div class="block">div.block 1</div>
<div class="block">div.block 2</div>
<div class="inline-block">div.inline-block 1</div>
<div class="inline-block">div.inline-block 2</div>
<button type-"button">
Add some style
</button>
const style = `
.inline-block {
text-decoration: underline;
}
.block {
display: block;
border: 1px dashed red;
margin: 2px;
padding: 2px;
}
`;
const addStyle = () => {
const css = document.createElement('style');
css.innerText = style;
document.head.appendChild(css);
};
document.querySelector('button')
.addEventListener('click', addStyle);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.