CSS detailed explanation

高洛峰
Release: 2016-10-20 13:26:45
Original
1150 people have browsed it

Introduction to CSS

1. Overview and function of CSS

CSS: Cascading Style Sheets) is a cascading style sheet used to define the display effect of web pages. It can solve the duplication of style definitions in HTML code, improve the maintainability of later style code, and enhance the display effect of web pages.
  Function: CSS separates web page content and display style, improving the display function.

2. Combination of CSS and HTML (*****) (four types)

 How to combine CSS and HTML

 1. Style attribute method:

Use the style attribute in the tag to change the display of each tag style.

 Example:


p tag paragraph content.


  This method is more flexible, but it is more troublesome to define the same style for multiple identical tags, so it is suitable for local modification.

 2. Style tag method: (embedded method)

  Add the style tag to the head tag to modify multiple tags uniformly. ​

<head>
    <style type=”text/css”>
        p { color:#FF0000;}
    </style></head>
Copy after login

​ This method can uniformly set the style of a single page, but it is not flexible enough for local areas.

  3. Import method: (commonly used method)

  The premise is that there is already a defined CSS file. If part of the style of the web page needs to be used, then use this method.

 Example:

<style type="text/css">
    @import url(css_3.css);
    div { color:#FF0000;}</style> 
Copy after login

 

  Define the end of an external CSS file (.css).
  @import url("css file address"); needs to be written inside the