Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Style sheet linking

Featured Replies

Hi guys,

 

I've always used an import style sheet but I've just noticed it's not the best practice and can significantly slow site load.

 

My question is, Previously in the header I link to one style sheet which uses @import a lot (because I often have several style sheets). Would it still be better to link all style sheets in the header?

 

I guess it goes against what I've learnt about JavaScript files and trying to keep them to a minimum.

 

Cheers,

Rob

To be honest, I'm not sure what the differences are between the usual link href and the @import method.

 

Some people with several stylesheets have one main stylesheet and the others linked into it with the @import code, so only one stylesheet uses the link href in the head section.

 

One thing I have noticed is that when dealing with problems on this forum, I can click a link href in the View Source in Firefox and it opens the stylesheet immediately but I can't clink a @import to open the file, I have to copy/paste the domain name and the copy/paste the @import name into a browser address bar to open it, which takes longer, so I like it when people use the link href method even for several stylesheets.

  • Author

Thanks for the reply.

 

I link in the header to a style sheet - where in that style sheet I import all other style sheets.

 

So in the header I use:

<link rel="stylesheet" href="import.css" type="text/css" media="screen">

 

Then in that style sheet use:

@import "css/resets.css";

@import "css/fonts.css";

@import "css/globalClasses.css";

@import "css/mainStyle.css";

 

^ for example

  • Author

Cheers for the input.

 

On reflection it looks like a better idea to link each sheet separately in the head. This also makes it easy to link to a specific ie sheet if needed. I guess with todays broadband speeds its not a massive performance issue, but still good practice.

 

How does everyone else currently do it?

Good article ElanMan, thanks for the link.

+1

How does everyone else currently do it?

 

I've never used @import. I just list all css files with the link in the head section.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.