Comparison of CSS syntax with JSON and JS objects and css syntax jsonjs
The CSS (Cascading Style Sheets) Rule consists of two parts: Selector and declaration.
Selector {declaration1; declaration2; declaration3;... declarationN}
Declaration is separated by semicolons (;). It is represented as property: value1 value2 .. It is a single layer non-nested structure.
Value indicates a specific value, such as px, color # FFFFFF, position relative/absolute, etc.
Selector can be separated by commas (,), such as h1, h2, h3, h4 ..
Note: When code CSS is used, the attribute values must be ordered or not.
Backgroud: color position size repeat attachment url ("img. url ") when rendering and parsing this type of attribute, the browser uses regular expressions to determine the type of value to modify the specified attribute. The order and value type can be freely matched.
Padding: left top right bottom and other attributes are parsed in sequence. to modify a specified attribute, you must complete the previous values.
JSON (Javascript Object Nonation) is composed of Object declarations.
{Declaration1, declaration2,... declarationN}
Its representation can be a tree-like multi-level nested structure, and the attributes of an object can be represented by one or more objects. The outer layers of multiple objects are closed by the JS array [] symbol, the object is closed by the collection symbol {}, and the ing relationship is indicated by a colon.
JS object
Composed of collection symbols {}, the content is attribute: value, separated by commas. The structure is similar to that of a JSON object, but its attributes do not have to be enclosed by quotation marks.
In summary, we can conclude that the JSON object is a subclass of the JS object, and the CSS object is a subclass of the JSON object, that is, CSS inherits the JS object.