How important is it to enqueue a theme’s stylesheet?

I have trawled the net looking for an answer to this, but for some reason all I can find are actual examples, but without that particular explanation, which is clear say in the case of scripts. Can someone explain to me why it’s important/advantageous to enqueue styles when developing a theme, rather than just using <link rel=stylesheet> in header.php.

Also, what about the theme’s default stylesheet, should that be enqueued too?

3

It’s important to enqueue the stylesheet because it will allow child themes the flexibility of dequeueing it as well as allowing it to be listed for dependencies and a multitude of other things. It just generally allows greater flexibility, both for you and for any other developers who interact with your code.

It’s also important to note that using the default stylesheet in your theme is not a requirement. The stylesheet must be PRESENT, but if you use it for nothing more than to name your theme, set the version, etc, wordpress is COMPLETELY fine with that, as are the people who approve themes for the main repository.

Leave a Comment