---
name: "up.element.style"
area: "API"
kind: "JavaScript function"
parent: "up.element module"
url: "https://unpoly.com/api/up.element.style"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.element module](https://unpoly.com/api/up.element.md)</nav>

# up.element.style(element, propOrProps)

Returns [computed CSS styles](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle) for the given element.

If a property is not set, it will be returned as an empty string.

<nav aria-label="Contents">

#### Contents

- [Examples](#examples)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Examples {#examples}

When requesting a single CSS property, its value will be returned as a string:

```js
let value = up.element.style(element, 'font-size')
// value is '16px'
```

When requesting multiple CSS properties, the function returns an object of property names and values:

```js
let value = up.element.style(element, ['font-size', 'margin-top'])
// value is { 'font-size': '16px', 'margin-top': '10px' }
```

---

## Parameters {#parameters}

### element {#element}

(required)

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)

### propOrProps {#propOrProps}

(required)

One or more CSS property names in kebab-case.

Type: string | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)

---

## Return value {#return-value}

The requested style value or values.

Type: string | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

