Home  >  Article  >  Web Front-end  >  What is css (cascading style sheets)?

What is css (cascading style sheets)?

青灯夜游
青灯夜游Original
2019-05-17 09:26:035961browse

CSS is the abbreviation of Cascading Style Sheets (Cascading Style Sheets). It is a computer language used to express file styles such as HTML (an application of Standard Generalized Markup Language) or XML (a subset of Standard Generalized Markup Language). .

CSS is mainly used to set the appearance of the website to make our website more gorgeous and eye-catching; it can not only statically modify web pages, but also dynamically coordinate with various script languages. Format various elements of the web page.

CSS can perform pixel-level precise control over the layout of element positions in web pages, supports almost all font size styles, and has the ability to edit web page objects and model styles.

CSS style sheets define the color, size, and position of text and other HTML markup, while HTML files define content and how it is organized. Separating them allows you to change the color scheme without having to rewrite the entire site.

Cascading means that styles applied to the parent element will also be applied to all child elements in the parent element. For example, setting the color of the body text will mean that all headings and paragraphs in the body text will also be the same color.

Specifying and using styles

There are three main ways to include a web page or site style sheet:

1. Set the attribute of the tag, which is called inline style;

2. Use the c9ccee2e6ea535a969eb3f532ad9fe89 tag in the HTML header tag, which is called embedded. Style;

3. Create and link to an external CSS file, called an external style sheet.

Basic style sheets usually modify the appearance of HTML tags such as 6c04bd5ca3fcae76e30b72ad730ca86d and e388a4556c0f65e1904146cc1a846bee. When using CSS files or stylesheets in header files, we can also define style classes and apply them to any element using the class="?" attribute, but this is beyond the scope of this simple guide.

Inline style

Features:

1) Inline style is placed in the HTML element in the code.

2) When using inline styles, the styles will only affect the elements you select.

3), inline styles have no selectors

Note: Inline styles defined in HTML only apply to the tags they are added to.

<p style="color:red;">Some red text</p>

Embedded style

Features:

1), placed in the style tag b30f827a0e5111390c73b8acc2f509d7 e90442d4aba9b6409c93259f982d1eec is written in the head section of the web page.

2), the style written will be used only for the web page you use it on.

3), embedded styles are also called "internal styles"

The styles defined in the header will be applied to the entire page. The example below will make all h1 tags in the page display the title in red.

<head>
   <style type="text/css"> 
       h1 { color: red; }
   </style>
</head>

External Style Sheet

Like HTML files, CSS files are plain text and usually have a .css file extension; they can be passed through specific tags to link it into the HTML file.

Features:

1), written in a separate document and then attached to various Web documents

2), modifying it can affect all pages you call

3), easy to modify

For example, the content of the style.css file can be as follows:

body { background-color: beige; color: #000080;}
h1 { color: red;}

Then you can use be98b57125ed9b2d8fbe917c785e8d94 The header is introduced to take effect.

<head>
<link rel="stylesheet" type="text/css" href="style.css" title="style">
</head>

Most websites today use external style sheets. External styles are styles that are written in separate documents and then attached to various web documents. External style sheets affect any files they are connected to, meaning if you have a 20 page website and every page uses the same style sheet, when changes need to be made you can simply edit the style sheet to complete those pages. Makes long-term site management easier. The disadvantage of external style sheets is that they require the page to obtain and load these external files. Not every page will use every style in the CSS table, so many will load a much larger CSS page than is actually needed.

The above is the detailed content of What is css (cascading style sheets)?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more