Search

Astro's Support Squid

RegisterLogin

Discussion

Getting Started
Client-side islands
Markdown / Markdoc / MDX
CMS
Images
CSS / Styling
Routing
TypeScript
Vite
Editor Setup
On-Demand Rendering
Deployment
Starlight
i18n
View Transitions
DB / Databases
Upgrade
Actions

Library

What is the best CMS for Astro
 Collections Links Members Roles

I created a basic Astro project and I added https://github.com/sindresorhus/modern-normalize to my project:

pnpm add modern-normalize. So far so good. I want normalize's stylesheet to be the first stylesheet in the generated HTML, but...

ID
d6ns525q4k7s73ar77o0
author
toromoro's avatar

toromoro

@toromoro


View profile
Copy link
  Report member
started
Mar 10, 2026
replies
0
participating
No

scroll to top

powered by storyden

Login
Discussion
CSS / Styling
I created a basic Astro project and I added https://github.com/sindresorhus/modern-normalize to my project:
toromoro's avatar

toromoro

@toromoro


View profile
Copy link
  Report member
• 4h
CSS / Styling

I created a basic Astro project and I added https://github.com/sindresorhus/modern-normalize to my project:

pnpm add modern-normalize.

So far so good. I want normalize's stylesheet to be the first stylesheet in the generated HTML, but for some reason the Welcome component's stylesheet appears first. I tried a two different methods and none have worked so far.

Attempt 1

---
import "modern-normalize/modern-normalize.css";
---

<!-- Layout.astro -->
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="generator" content={Astro.generator} />
    <title>Astro</title>
  </head>
  <body>
    <slot />
  </body>
</html>

I inspected the generated index.html file under dist/, and modern-normalize.css appears after the Welcome component's styles.

Attempt 2

<!-- Layout.astro -->
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="generator" content={Astro.generator} />
    <title>Astro</title>
    <style>
      @import "modern-normalize/modern-normalize.css";
    </style>
  </head>
  <body>
    <slot />
  </body>
</html>

In the generated index.B2quw3j1.css file, normalize, once again, appears after the Welcome component's CSS.

I know that the Welcome component's CSS is scoped to it, but is there a way to make modern-normalize.css appear before the rest of CSS?

0 likes0 replies

    Please sign up or log in to reply