Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the ways to nest and use CSS in HTML pages

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article, "what are the methods of using CSS nested in the HTML page?", so the editor summarizes the following, detailed contents, clear steps, and a certain reference value. I hope you can get something after reading this article. Let's take a look at this article, "what are the methods of using CSS nested in the HTML page?"

What is CSS?

CSS (Cascading Style Sheet): cascading stylesheet language.

The purpose of CSS is to:

Decorate the HTML page and style some elements in the HTML page to make the HTML page look better.

Two ways to nest and use CSS in HTML pages

The first way: use the style attribute inside the tag to set the CSS style of the element, which is called inline definition. Syntax format:

The second way: link to an external stylesheet file, which is the most commonly used. (write the style into a separate xxx.css file, introduce the css file directly into the web page you need, and the style is introduced.) Syntax format:

This method is easy to maintain and the maintenance cost is low. Xxx.css file 1.html introduced 2.html, 3.html introduced 4.html, introduced three ways of code presentation

Inline definition mode

The first way to introduce CSS style into HTML: inline definition

Style block mode

The second way to introduce styles in HTML: style block mode / * this is the comment of CSS * / / * id selector # id {style name: style valu Style name: style value; style name: style value. } * / # usernameErrorMsg {font-size: 12px; color: red } / * tag selector signature {style name: style value; style name: style value Style name: style value;} * / div {background-color: black; border: 1px solid red Width: 100px; height: 100px;} / * class selector. Class name {style name: style valu } * / .myclass {border: 2px double blue; width: 400px; height: 30px}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report