02-28-2005, 11:40 AM
I'm writing a CMS system at the moment and part of what I wanted to do was allow users to attach their own custom external css files to pages if they need to, not to replace the existing css file but to append it.
Is it valid to attach multiple css files to one page or will it cause problems? Also, how are things like element name conflicts resolved, is priority given to the last declared css element or the first, etc?
Thanks in advance for any help you can offer.
02-28-2005, 11:48 AM
multiple style sheets are ok....
but im not sure how conflict is resolved.
02-28-2005, 11:53 AM
Hmm, well I guess I could always append some text to the beginning of my own elements to make it more unlikely that people will try to add duplicate elements. I also have a feeling that the later defined css would take precedence but I don't know if that's true, it just seems to make more sense.
Thanks for the info :thumbsup:
02-28-2005, 11:56 AM
Several stylesheets are indeed allowed. The resolution is simple: all things from all style rules are applied to everything the selectors match. Properties from rules with higher selector specificity override properties from rules with lesser specificity. If the same property is applied from two rules with the same selector specificity, the last one in source order will override those before.
02-28-2005, 12:06 PM
Lets say you have a style called .leftcontent
And someone else has a style called .leftcontent
The last instance in the style sheet will be applied to that page/site.
Yes, you can have multiple stylesheets in the same document.
02-28-2005, 01:14 PM
Excellent, so as long as I insert the master stylesheet after any user-created stylesheet mine should take priority. Just what I needed to know, thanks :D
Sounds like you are trying to do something similar to me.
If you could explain your application, I might have a solution for your specific issue.
03-01-2005, 04:49 AM
Sounds kinda like what myspace.com has. You can edit into the text fields any CSS you want. You can view thier css page and pick the values you want to change. Since thiers is in the head, anything the user puts into a text feild takes precedence.
They went a long way building a lot of the layout in tables so that there were a good bit of uneditable properties of the page.