Comparison of CSS syntax with JSON and JS objects and css syntax jsonjs

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.