CSS

Include CSS in CSS

Include CSS in CSS with just 1 line of code. Read on to find out more about this nifty little trick.

Include CSS in CSS

Let us say that you have a main CSS file called “main.css” that contains all the styles for your website. Now you want to include a CSS file that works as a CSS Reset (If you do not know what CSS Reset, is then read more about it here), you can do it the following way, assuming that your CSS Reset file is name as “reset.css”:

//Contents of main.css

@import url("reset.css");

h1 { }
h2 { }
p { }

@import url(“reset.css”); is the only line of code you need to include css in css. You can apply the same method to include multiple css in a single css file. Following is an example:

//Contents of main.css

@import url("reset.css");
@import url("colors.css");
@import url("forms.css");

h1 { }
h2 { }
p { }

So as you can see, all you need is just 1 line of code whenever you want to include CSS in another CSS.

Share your thoughts, comment below now!

*

*