Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS Background shorthand

Sorry to ask such a basic question, but in spite of the fact that I am not a professional webdesigner, but I already have some more elaborated personal websites than only show one static picture in one static page, I am completely confused, and I am fed up.
OK, that even if I do not put in the right order of CSS properties, the browser shows what I want, but I would like to know if there is an official order for the background properties.

W3 School says (It does not give all): background-color background-image background-repeat background-attachment background-position.

Mozilla Developer says: background-repeat background-attachement background-position / background-size background-origin background-clip background-image background-color;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Webfx says: background-image background-position / background-size background-repeat background-attachment background-origin background-clip background-color;

I give up going to look for the official order, because I am not able to decide myself which is the right official one.

Can you tell me how you know it, and from which website can say the official CSS rules ? Or, is there an official CSS statement that background properties order is not important ?

>Solution :

MDN links to the official specifications which say:

This specification follows the CSS property definition conventions from [CSS2] using the value definition syntax from [CSS-VALUES-3].

That then links to this document which describes, in detail, how to read the syntax definitions.

The most relevant part of that is:

A double bar (||) separates two or more options: one or more of them must occur, in any order.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading