📜  css interne - CSS (1)

📅  最后修改于: 2023-12-03 15:00:05.313000             🧑  作者: Mango

CSS Internals - CSS

CSS (Cascading Style Sheets) is a style sheet language used to describe the presentation of a document written in HTML or XML. It is used to control the layout and styling of web pages, including fonts, colors, margins, and backgrounds.

CSS Parsing

When a web browser loads an HTML document, it starts parsing the document from top to bottom. When it encounters a <link> tag with the rel attribute set to stylesheet, the browser creates a new CSS parser.

The CSS parser reads the CSS file and creates a stylesheet object, which is then passed to the rendering engine. The rendering engine combines the HTML and stylesheet objects to render the web page on screen.

Cascading

Cascading is the process by which the browser determines which styles to apply to an element. CSS styles are applied based on the following criteria:

  1. Specificity: The more specific a selector is, the higher its precedence.
  2. Inheritance: Some CSS properties are inherited from parent elements.
  3. Order: The order in which styles are written in the CSS document matters. Styles at the bottom of the document will override styles higher up in the document.
Box Model

The CSS box model is used to describe the layout of HTML elements. It consists of four parts:

  1. Content: The content of the box, such as text or images.
  2. Padding: The space between the content and the border.
  3. Border: The line that surrounds the content and padding.
  4. Margin: The space between the border of the box and other elements on the web page.
Layout

CSS offers a wide range of layout options. Some of the most commonly used layout techniques include:

  1. Floats: An element can be floated to the left or right, causing other elements to wrap around it.
  2. Positioning: An element can be positioned absolutely, fixed, or relative to its parent.
  3. Display: Elements can be displayed as blocks, inline, or inline-block.
Conclusion

CSS is a versatile styling language that allows programmers to control the presentation of web pages. It offers a wide range of layout options and is an essential part of modern web development.

# CSS Internals - CSS

CSS (Cascading Style Sheets) is a style sheet language used to describe the presentation of a document written in HTML or XML. It is used to control the layout and styling of web pages, including fonts, colors, margins, and backgrounds.

## CSS Parsing

When a web browser loads an HTML document, it starts parsing the document from top to bottom. When it encounters a `<link>` tag with the `rel` attribute set to `stylesheet`, the browser creates a new CSS parser.

The CSS parser reads the CSS file and creates a stylesheet object, which is then passed to the rendering engine. The rendering engine combines the HTML and stylesheet objects to render the web page on screen.

## Cascading

Cascading is the process by which the browser determines which styles to apply to an element. CSS styles are applied based on the following criteria:

1. **Specificity**: The more specific a selector is, the higher its precedence.
2. **Inheritance**: Some CSS properties are inherited from parent elements.
3. **Order**: The order in which styles are written in the CSS document matters. Styles at the bottom of the document will override styles higher up in the document.

## Box Model

The CSS box model is used to describe the layout of HTML elements. It consists of four parts:

1. **Content**: The content of the box, such as text or images.
2. **Padding**: The space between the content and the border.
3. **Border**: The line that surrounds the content and padding.
4. **Margin**: The space between the border of the box and other elements on the web page.

## Layout

CSS offers a wide range of layout options. Some of the most commonly used layout techniques include:

1. **Floats**: An element can be floated to the left or right, causing other elements to wrap around it.
2. **Positioning**: An element can be positioned absolutely, fixed, or relative to its parent.
3. **Display**: Elements can be displayed as blocks, inline, or inline-block.

## Conclusion

CSS is a versatile styling language that allows programmers to control the presentation of web pages. It offers a wide range of layout options and is an essential part of modern web development.