CSS Basis_2

本文详细介绍了HTML中的class和id属性,class用于定义相同样式的元素集合,而id则是独一无二的标识。CSS伪类允许开发者在用户与元素交互时应用特定样式,如鼠标悬停、链接状态等。此外,还阐述了CSS盒模型,它包括元素的内容、内边距、边框和外边距。
摘要由CSDN通过智能技术生成

目录

HTML CLASS

HTML id

Difference Between Class and ID:

CSS伪类(pseudo-class):

CSS Box Model:


HTML CLASS

• The HTML class attribute is used to define equal styles for elements with the same class name.

• All HTML elements with the same class attribute will have the same format and style.

• To style elements with a specific class, write a period (.) character, followed by the name of the class

HTML id

The HTML id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document)

• The id value can be used by CSS and JavaScript to perform certain tasks for a unique element with the specified id value.

• To style an element with a specific id, write a hash (#) character, followed by the id of the element.

Difference Between Class and ID:

• An HTML element can only have one unique id that belongs to that single element

• A class name can be used by multiple elements 

CSS伪类(pseudo-class):


- 当用户将鼠标移到一个元素上时,对该元素进行样式设计
- 对已访问和未访问的链接采用不同的样式
- 当一个元素获得焦点时为其设计样式

设置当用户和网页上的事物发生交互作用时产生的效果

selector: pseudo-class {property:value;}

 

 A CSS comment starts with /* and ends with */. Comments can also span multiple lines:

CSS Box Model:

The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content. 

 

 (Remember: When you set the width and height properties of an element with CSS, you just set the width and height of the content area.)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值