Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the second of two consecutively invoked stylesheets override all styles defined in the first?

If I have a HTML page that links to two stylesheets that are invoked like this:

<link rel="stylesheet" href="original.css" media="screen, projection" />
<link rel="stylesheet" href="override.css" media="screen, projection" />

If these two files define the exact same style names, is it true that original.css will have no bearing on the outcome of the styled page and that all styles will come from the styles defined in override.css?

The reason I ask is this: I have an original.css that I cannot modify and I do not want to touch the lines of code that invoke this file. Instead I would like to insert a call to my new file right after the original is called and override everything defined in the original. I'm not sure if this will work, whether it's advisable, etc.

like image 456
brian Avatar asked Nov 22 '25 09:11

brian


1 Answers

Yep, it sure can. That's the Cascading bit of Cascading Style Sheets.

I gotta ask though, why can't you just delete original.css, or not output it, or.... something? It seems like a very Big Hammer approach to completely override everything in original :-) If you do indeed output original.css and override.css, the browser is going to have to do a whole lot more work than if you were to just output override.css.

like image 92
Dan F Avatar answered Nov 24 '25 04:11

Dan F