Home > Web Front-end > CSS Tutorial > Detailed description of CSS in JavaWeb

Detailed description of CSS in JavaWeb

高洛峰
Release: 2017-03-17 11:51:45
Original
1503 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)

Combination of CSS and HTML

1. Style attribute method:

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

Example:

<p style="background-color:#FF0000; color:#FFFFFF">
        p标签段落内容。</p>
Copy after login

This method is more flexible, but it is more troublesome to define the same style for multiple identical tags and 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);
    p { color:#FF0000;}</style>  
Copy after login

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