# What was that other way to set CSS styles?

**URL:** <https://forum.kirupa.com/t/what-was-that-other-way-to-set-css-styles/650117>\
**Category:** web dev\
**Created:** [December 20, 2021, 9:39pm UTC](https://forum.kirupa.com/t/what-was-that-other-way-to-set-css-styles/650117 "2021-12-20T21:39:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [December 21, 2021, 5:17pm UTC](https://forum.kirupa.com/t/what-was-that-other-way-to-set-css-styles/650117/2 "2021-12-21T17:17:41Z")

</div>

Hmm. not sure. Do you mean this?

> [@JS Tip of the Day: Setting HTML Element Styles](http://forum.kirupa.com/t/js-tip-of-the-day-setting-html-element-styles/643124):
>
> Setting HTML Element Styles Level: Beginner In JavaScript, you can set css styles for an element using its style property. This mirrors the style attribute in HTML but with a couple of important differences. First, the style property is an object in JavaScript, not a string value as it is in the HTML attribute. This object is a CSSStyleDeclaration object with each of the individual style declarations defined as properties of that object. \<div id="warning" style="color: red"\> Danger, Will R…

Not sure if there’s anything clever there. I searched through a few of the other tips to see if there was anything else I was doing but nothing jumped out.

Sometimes I will do something like this, maybe something like this is what you remember seeing?

```javascript
let color = "red"
let fontSize = "2em"
let fontWeight = "bolder"

Object.assign(element.style, {
  color,
  fontSize,
  fontWeight,
})

```

Edit: I just found a tip that does this ^: [JS Tip of the Day: MutationObserver](http://forum.kirupa.com/t/js-tip-of-the-day-mutationobserver/643095)

P.S. I noticed a few broken links in the Tips page. I didn’t check them all but these are the ones I found that were broken or needed fixing:

- Reduce Code with Destructuring → [JS Tip of the Day: Reduce Code with Destructuring](http://forum.kirupa.com/t/js-tip-of-the-day-reduce-code-with-destructuring/643176)
- Numeric literal formats → [JS Tip of the Day: Numeric Literal Formats](http://forum.kirupa.com/t/js-tip-of-the-day-numeric-literal-formats/643150)
- Proxy Objects → [JS Tip of the Day: Proxy Objects](http://forum.kirupa.com/t/js-tip-of-the-day-proxy-objects/643118)
- Detecting Dark Mode → [JS Tip of the Day: Detecting Dark Mode](http://forum.kirupa.com/t/js-tip-of-the-day-detecting-dark-mode/643179)

---

_[View the full topic](https://forum.kirupa.com/t/what-was-that-other-way-to-set-css-styles/650117)._
