search
HomeWeb Front-endHTML TutorialHTML与CSS入门--第四章 理解层叠样式表_html/css_WEB-ITnose

知识点:

  1.创建基本样式表的方法

  2.使用样式类的方法

  3.使用样式ID的方法

  4.构建内部样式表和嵌入样式的方法

4.1 CSS工作原理:

  CSS:层叠样式表的缩写,是一种定义样式结构如字体、颜色、位置等的语言,被用于描述网页上的信息格式化和实现的方式。

  扩展名:.css

  分内部样式表,外部样式表以及内联样式表

  "层叠"的概念理解:(有助于理解CSS的优先级)CSS样式表中的样式会形成一个层次结构,更具体的样式会覆盖通用的样式。优先级由CSS根据这个层级结构决定,从而实现级联效果。可以用类似继承的关系来理解。

  PS:元素的概念:表示标签及其内部的描述信息(如属性、文本、图像等)。

4.2 一个基本的样式表:

  标准的额书写方式:一行一个样式规则,便于阅读。

  字体专栏,需要抓一个时间段来分析一下,包括字体家族以及字体大小

  简单地列一下字体大小的各种单位:

    pt:点,1英寸相当于72点

    in:英寸

    cm:厘米

    px:像素

    em:字母m的宽度

4.3 CSS样式入门:

  CSS中的样式属性分为两大类:

    布局属性:影响网页上元素位置的属性。

    格式化属性:影响网站中元素的视觉显示的属性。

  布局属性之display:  block:块元素,自带clear:both

              list-item:列表项处理  /*从目前的实际角度来看与block没有什么区别*/

              inline,none,其他……

  布局属性之width,height

  格式化属性之border:最新增加border-radius可以控制矩形的圆角

  格式化属性之font:

    1.text-decoration常用于删去链接的下划线

    2.line-height设置文本行高

4.4 使用样式类:

  当需要使网页中的有些文本域其他文本不同时,可以通过创建自定义HTML标签。

  我们这里所说的定义的特殊格式文本称为样式类。因此它使一组自定义的格式化说明。例子:

    h1 { color:blue }

  h1是选择符;color是样式属性;blue是该属性的值

  选择符:标签(h1),类(.title),ID(#container)等……

  PS:注意组合选择器中"标签.类"与"标签 .类"的区别。

4.5 使用样式ID:

  出于布局,格式化,与后台交互的考虑都可以选择使用ID。

  ID在同一个页面中必须唯一存在。

4.6 内部样式表和内联样式:

  内部样式表:

  内联样式:style属性

  PS:外部样式表,link,注意需要href,type以及rel属性

 

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
HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool