CSS Getting started knowledge point finishing
Don't mock me for this konjac konjac. Example Source: W3school
CSS is actually divided into two things, one is a selector, the other is a statement. A declaration defines the value of an object's properties, which are the contents of the HTML. The focus is on selectors. As the name implies, selectors are used to "select" Elements in HTML. By defining selectors, you can select certain elements in an HTML document and then change their style to a declaration. CSS has a long format like this:
selector {declaration1; declaration2; ... declarationn}
Here is one of the most basic examples of CSS:
h1 {color:red; font-size:14px;}
This means that all elements that are h1 are colored red and the font size is set to 14 pixels.
Selectors have many uses:
-
Descendant selector x y{...}. Its function is that only the Y element in the X element will be selected. The preceding is the equivalent of the X set to all elements.
-
child element selector x>y{...}. Its function is similar to that of a descendant selector, but only the descendants of the next layer can be selected.
-
Brother Selector x+y{...}. Its function is that only and X are the siblings of the element y will be selected.
The first three selectors are collectively referred to as derived selectors. They can also be combined with the following selectors.
-
ID selector #idName {...}. It can select all the elements of the id=idname. Note that ID is not recommended for sharing.
-
Class selector. classname{...}. It can select all the elements of the class=classname.
-
Title selector [title=x]{...}. It can select all the elements of the title=x. The equals sign is replaced by ~=/|=, meaning that you can match any of the substrings in X (separated by spaces/used-split).
That's it.
CSS Getting started knowledge point finishing