0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-10 22:38:53 -05:00
astro/.changeset/small-bugs-prove.md
Matthew Phillips 01c1aaa003
Fix CSS ordering between imported and Astro styles (#4907)
* Fix CSS ordering between imported and Astro styles

* Fix linting errors

* Add changeset and upgrade compiler version

* Update test to reflect shared styles placed before page styles
2022-09-28 18:12:22 -04:00

775 B

astro
minor

Order Astro styles last, to override imported styles

This fixes CSS ordering so that imported styles are placed higher than page/component level styles. This means that if you do:

---
import '../styles/global.css';
---
<style>
  body {
    background: limegreen;
  }
</style>

The <style> defined in this component will be placed below the imported CSS. When compiled for production this will result in something like this:

/* /src/styles/global.css */
body {
  background: blue;
}

/* /src/pages/index.astro */
body:where(.astro-12345) {
  background: limegreen;
}

Given Astro's 0-specificity hashing, this change effectively makes it so that Astro styles "win" when they have the same specificity as global styles.