[Bootstrap Basics] 04. The HTML and CSS coding specifications of Bootstrap, bootstrapcss
HTML
CSS
- Use two spaces to replace tabs-this is the only way to ensure consistent display in all environments.
- When grouping a selector, separate the selector into one row.
- For ease of coding, add a space before the left curly braces of each declared block.
- The right curly braces of the block should be arranged separately.
- The
:
Insert a space.
- For more accurate error reports, each statement should have an exclusive row.
- All declaration statements should end with a semicolon. The semicolon following the last statement is optional. However, if you omit this semicolon, your code may be more error-prone.
- For attribute values separated by commas, a space should be inserted after each comma (for example,
box-shadow
).
- Do not
rgb()
,rgba()
,hsl()
,hsla()
Orrect()
ValueInternalInsert a space after a comma. This facilitates the division of multiple color values from multiple attribute values (both comma and space ).
- For attribute values or color parameters, omit the value 0 before the decimal point smaller than 1 (for example,
.5
Replace0.5
;-.5px
Replace-0.5px
).
- Hexadecimal values should all be in lower case, for example,
#fff
. When scanning documents, lowercase characters are easy to distinguish because their forms are easier to distinguish.
- Try to use the hexadecimal value in short form, for example
#fff
Replace#ffffff
.
- Add double quotation marks to attributes in the selector. For example,
input[type="text"]
. It is optional only in some cases. However, double quotation marks are recommended for code consistency.
- Avoid specifying the unit for the value 0. For example, use
margin: 0;
Replacemargin: 0px;
./* Non-conforming CSS */. selector ,. selector-secondary ,. selector [type = text] {padding: 15px; margin: 0px 0px 15px; background-color: rgba (0, 0, 0, 0.5); box-shadow: 0px 1px 2px # CCC, inset 0 1px 0 # FFFFFF}/* compliant CSS */. selector ,. selector-secondary ,. selector [type = "text"] {padding: 15px; margin-bottom: 15px; background-color: rgba (0, 0 ,. 5); box-shadow: 0 1px 2px # ccc, inset 0 1px 0 # fff ;}
- The relevant attribute Declaration should be a group and arranged in the following order:
Positioning can remove elements from normal document streams and overwrite box model styles. The box model ranks second because it determines the size and position of the component.
Other attributes only affect the internal (inside) of the component, or do not affect the first two sets of attributes.
To be honest and wise, the so-called norms are what everyone agrees to write code together.
I read the above on the Internet. I don't know whether to declare or not to repost. Some of them are reprinted, which is too troublesome. They are all basic things. Forget it.