# Vanilla Extract Documentation
# Source: https://raw.githubusercontent.com/vanilla-extract-css/vanilla-extract/master/site/docs/global-api/global-style.md
# Path: site/docs/global-api/global-style.md

---
title: globalStyle
parent: global-api
---

# globalStyle

Creates styles attached to a global selector.

Requires a selector string as the first parameter, followed by a style object.

```ts compiled
// app.css.ts

import { globalStyle } from '@vanilla-extract/css';

globalStyle('html, body', {
  margin: 0
});
```

> 🧠&nbsp;&nbsp;The global style object cannot use [simple pseudo](/documentation/styling#simple-pseudo-selectors) or [complex selectors](/documentation/styling/#complex-selectors).
> This avoids unexpected results when merging with the global selector, e.g. `ul li:first-child, a > span`.

Global selectors can also contain references to other scoped class names.

```ts compiled
// app.css.ts

import { style, globalStyle } from '@vanilla-extract/css';

export const parentClass = style({});

globalStyle(`${parentClass} > a`, {
  color: 'pink'
});
```