
- Next.js - Home
- Next.js - Overview
- Next.js - Project Setup
- Next.js - Folder Structure
- Next.js - App Router
- Next.js - Page Router
- Next.js Features
- Next.js - Pages
- Next.js - Data Fetching
- Next.js - ISR
- Next.js - Static File Serving
- Next.js - Pre-Rendering
- Next.js - Partial Pre Rendering
- Next.js - Server Side Rendering
- Next.js - Client Side Rendering
- Next.js Routing
- Next.js - Routing
- Next.js - Nested Routing
- Next.js - Dynamic Routing
- Next.js - Parallel Routing
- Next.js - Imperative Routing
- Next.js - Shallow Routing
- Next.js - Intercepting Routes
- Next.js - Redirecting Routes
- Next.js - Navigation and Linking
- Next.js Configuration
- Next.js - TypeScript
- Next.js - Environment Variables
- Next.js - File Conventions
- Next.js - ESLint
- Next.js API & Backend
- Next.js - API Routes
- Next.js - Dynamic API Routes
- Next.js - Route Handlers
- Next.js - API MiddleWares
- Next.js - Response Helpers
- Next.js API Reference
- Next.js - CLI Commands
- Next.js - Functions
- Next.js - Directives
- Next.js - Components
- Next.js - Image Component
- Next.js - Font Component
- Next.js - Head Component
- Next.js - Form Component
- Next.js - Link Component
- Next.js - Script Component
- Next.js Styling & SEO
- Next.js - CSS Support
- Next.js - Global CSS Support
- Next.js - Meta Data
- Next.js Advanced Topics
- Next.js - Error Handling
- Next.js - Server Actions
- Next.js - Fast Refresh
- Next.js - Internationalization
- Next.js - Authentication
- Next.js - Session Management
- Next.js - Authorization
- Next.js - Caching
- Next.js - Data Caching
- Next.js - Router Caching
- Next.js - Full Route Caching
- Next.js - Request Memoization
- Next.js Performance Optimization
- Next.js - Optimizations
- Next.js - Image Optimization
- Next.js - Lazy Loading
- Next.js - Font Optimization
- Next.js - Video Optimization
- Next.js - Script Optimization
- Next.js - Memory Optimization
- Next.js - Using OpenTelemetry
- Next.js - Package Bundling Optimization
- Next.js Testing
- Next.js - Testing
- Next.js - Testing with Jest
- Next.js - Testing with Cypress
- Next.js - Testing with Vitest
- Next.js - Testing with Playwright
- Next.js Debugging & Deployment
- Next.js - Debugging
- Next.js - Deployment
- Next.js Useful Resources
- Next.js - Interview Questions
- Next.js - Quick Guide
- Next.js - Useful Resources
- Next.js - Discussion
Next.js - Global CSS
Next.js provide a separate global css file to declare CSS styles that affect all pages in an application. In this chapter we will learn how to apply global CSS to a Next.js application.
Next.js Global Styles
Global CSS refers to styles that apply to the entire application rather than being scoped to individual components. These styles are typically defined in a CSS file and imported at a central entry point, such as the _app.js file in a Next.js project.
Create a Global CSS File
If you are using App router for your Next.js project, you will already have global.css file in project's app folder. For page router you can find global css file inside the styles folder. Paste the following code in your global css file.
// /app/global.css div { font-family: Arial, sans-serif; padding: 20px; background-color: #f9f9f9; border: 2px solid; border-radius: 10px; max-width: 400px; } h1 { color: #0070f3; } h2 { color: #333; }
Import Global CSS
Importing of global CSS is done at layout component. This is a special component, that is visible in every routes and style applied to this component will applicable to all other components.
// app/layout.tsx import './/globals.css'; // import CSS interface RootLayoutProps { children: ReactNode; } export default function RootLayout({ children }: RootLayoutProps) { return ( <html lang="en"> <body> <header> <h1>Header Element</h1> </header> <main>{children}</main> </body> </html> ); }
Output
In the output, style applied is reflecting in every pages.

Next.js Global Style Rules
- You cannot directly import global CSS in components. Imports must be done at the root level.
- Global CSS applies styles to every components in projects.
- Only .css files are supported for Global CSS imports. Other preprocessors like Sass require configuration.