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

If I have an HTML page that links to two stylesheets that are invoked as follows:

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

If these two files define the same style names, is it true that original.cssit will not affect the result of the stylized page and that all styles will be obtained from the styles defined in override.css?

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

+3
source share
4 answers

Oh sure. This is the cascading bit of cascading style sheets.

I have to ask why, why you can’t just delete original.css or not output it, or ... something? It seems that Hammer’s very large approach completely cancels everything in the original :-) If you really go to the source .css and override.css, the browser will have to do a lot more work than if you just quit override.css.

+4
source

Yes it will work. You are right that this is really not recommended. Instead of "not touching" the source lines of code, could you insert comment tags in it?

+4
source

, , , , id - . , IE:

original.css -

p { margin: 4px 6px 10px 12px; }
h1 { font-size: 2.2em }

override.css -

p { padding: 6px; color: #666666; }
h1 { font-size: 1.5em }

, P override.css, . , H1 , , .

, ... moodle, , . DEFAULT, PAGE, COURSE. , , , ... , , . , ----.

, .

Bye.

+1

A great example of this need is Sharepoint. Editing any theme will leave you with a number of changes that need to be redefined from the core.css class.

+1
source

Source: https://habr.com/ru/post/1711423/


All Articles