How to Include One CSS File in Another? Last Updated : 20 Jan, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Here are the methods to include one CSS file in another:Method 1. Using @import RuleThe @import rule allows you to import one CSS file into another, enabling modularity and reusability of styles. html <html> <head> <link rel="stylesheet" href="styles.css"> </head> <body> <h1 class="title">Hello, GeeksforGeeks!</h1> <p class="content">This is an example of including one CSS file in another.</p> </body> </html> styles.css CSS @import url('additional-styles.css'); body { font-family: Arial, sans-serif; margin: 20px; } .title { color: green; text-align: center; } .content { font-size: 16px; line-height: 1.5; } additional-styles.css HTML <!DOCTYPE html> <html> <head> <title>To include one CSS file in another</title> <style> @import "style.css"; h1 { color: green; } .geeks { color: black; background-image: linear-gradient(to right, #DFF1DF, #11A00C); position: static; } </style> </head> <body> <h1>GeeksforGeeks</h1> <div class="geeks"> GeeksforGeeks: It is a computer science portal. It is an educational website. Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. </div> </body> </html> The @import rule in styles.css includes additional-styles.css, ensuring that all styles from the additional file are applied.This approach keeps styles modular and reusable across multiple files.Method 2. Using Preprocessors like SCSSIf you’re using SCSS (Sass), you can use the @import directive to include one file in another. HTML <html> <head> <link rel="stylesheet" href="main.css"> </head> <body> <h1 class="header">Welcome to GeeksforGeeks!</h1> <p class="text">This is a demo of including CSS files with SCSS.</p> </body> </html> main.scss CSS @import 'variables'; @import 'typography'; body { margin: 0; padding: 0; font-family: 'Roboto', sans-serif; } _variables.scss CSS $primary-color: #008000; $secondary-color: #333; _typography.scss CSS .header { color: $primary-color; text-align: center; font-size: 2rem; } .text { color: $secondary-color; font-size: 1rem; line-height: 1.6; } SCSS files use the @import directive to include partials (like _variables.scss and _typography.scss).After compiling SCSS, a single main.css file is generated for use in the HTML. How to include one CSS file in another? Comment More infoAdvertise with us Next Article Create an Unordered List Without Bullets using CSS S Sabya_Samadder Follow Improve Article Tags : Technical Scripter Web Technologies CSS Technical Scripter 2018 Similar Reads How to Auto-Resize an Image to Fit a Div Container? To resize an image or video to fit inside a div container, use the object-fit property for precise control over how the content fits.object-fit maintains the aspect ratio or stretches the content to fill the container.Common values include cover (fills the container, may crop) and contain (fits with 3 min read How to Disable Resizable Property of Textarea using CSS? The resize property is used to disable the resizeable property of Textarea using CSS, by setting the resize property to none.Note: The resize property in CSS controls whether an element, like a textarea, can be resized by the user.Disable Resizing of TextareaThe resize property in CSS controls an el 1 min read Create an Unordered List Without Bullets using CSS To create an unordered list without bullet points, the CSS list-style-type property is used. This removes the default bullet points from the list items, and making the list appear plain.Table of ContentUsing list-style-type property Remove margin and padding after removing bullet pointsUnordered Lis 1 min read Set cellpadding and cellspacing in CSS Cell Padding The cell padding is used to define the spaces between the cells and its border. If cell padding property is not applied then it will be set as the default value. Example: html <!DOCTYPE html> <html> <head> <title>cell padding</title> <style> table, th 1 min read How to overlay one div over another div using CSS Creating an overlay effect simply means putting two div together at the same place but both the div appear when needed i.e while hovering or while clicking on one of the div to make the second one appear. Overlays are very clean and give the webpage a tidy look. It looks sophisticated and is simple 2 min read How to disable a link using only CSS? To disable a link using CSS, pointer-events can be used, which sets whether the element in the page has to respond or not while clicking on elements. The pointer-events property is used to specify whether the element should respond to pointer events or not. The following example illustrates this app 3 min read What does the â+â (plus sign) CSS selector mean? The "+" (plus sign) CSS selector, known as the adjacent sibling selector, targets the first element that immediately follows another specified element in the HTML structure. It applies styles only to the directly adjacent sibling after the selected element. Note: The IE8 and earlier versions </DO 1 min read How to Vertically Center Text with CSS? Here are three different ways to Vertically center text in CSS. Vertically center text means aligning text to appear in the middle of its container element.1. Using display PropertyWe can use display: flex to make the container as a flexbox and then applying the align-items: center to vertically cen 2 min read How to horizontally center a div using CSS ? To make an HTML div center horizontally using CSS is quite easy. We can horizontally center any element using the below-mentioned approaches. Before centering a div horizontally we need to create a fixed-size div. We have given a border to the div so the centering of that div can be visible. Set the 2 min read Change an HTML5 input placeholder color with CSS The placeholder selector in the CSS pseudo-element is used to design the placeholder text by changing the text color and it allows to modify the style of the text. In most of the browsers, the placeholder (inside the input tag) is of grey color. In order to change the color of this placeholder, non- 2 min read Like