Liberty Lover
Liberty Lover

Reputation: 1002

Is CSS <style> .. </style> data cached by the browser?

If I put all of my CSS in <style> .. </style> tags, will the browser cache that style data and apply it to either reloads of the same page or other pages on my web site?

Upvotes: 0

Views: 579

Answers (1)

ssc-hrep3
ssc-hrep3

Reputation: 16069

If your style is part of the HTML page, it is only cached together with the whole page. If you need the style on separate pages, it needs to be loaded everytime. You should use one style file with all the relevant styles in it and refer to it with <link rel="stylesheet" href="stylesheet.css">. This file is then cached (if your HTTP header says so) and can be used in every HTML page.

Upvotes: 1

Related Questions