> For the complete documentation index, see [llms.txt](https://jscula.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jscula.gitbook.io/docs/manipulation/.width.md).

# .width()

Gets or sets an element width. Numbers are treated as pixel values.

```javascript
$('#panel').width(480);
```

```javascript
$('#panel').width(current => current / 2);
```

```javascript
const width = $('#panel').width();
const totalWidth = $('.panel*').width();
```

### Use cases

Use `.width()` to:

* Set a fixed width for a panel.
* Keep an element above a minimum width.

### More examples

Ensure a sidebar remains at least 280 pixels wide:

```javascript
$('#sidebar').width(current => Math.max(current, 280));
```
