CSS基础
引用方法:
基本语句结构:选择符{属性1:属性值1;属性2:属性值2}
选择符:可以是HTML中任何的标识符,比如TR、TD、P、DIV、IMG甚至BODY都可以作为选
择符。 选择符中的内容将会以大括号内属性值定义的格式来显示。
除了选择符外,css还提供了几种选择器来让html调用css:
群选择器:当几个元素样式属性一样时,可以共同调用一个声明,元素之间用逗号分隔,:
p, td, li { font-size : 12px ; }
id选择器:用CSS布局主要用层"div"来实现,而div的样式通过"id选择器"来定义。
例如我们首先定义一个层
menubar is the style we want to use, and it is defined like this in the style sheet.
Just add a # in front!
Category selector: If you want to use class="" to reference the style, then you need a category selector, which is
The method is to add a "." before the selector in the definition
For example: .14px {color: #f60;font-size:14px; }
At this point it can be called via .
---------------------------------- ----------------------------------
Basic The css calls have been reviewed. As long as you learn to write css and use these calling methods, you can play with web pages.
CSS has countless attributes. However, like any language, as long as you master 1/3 of the common attributes, you can achieve 90% of the functions.So let’s learn the commonly used ones first.
Common CSS attributes:
Font attributes:
This is the most basic attribute, which mainly includes the following attributes:
Because the font attribute is often used, Tuotuo is familiar with it, so I will skip it for now.
Color and background properties
The usage is like this
Attribute: background Attribute value: a:hover {font-weight : bold ;text-decoration : underline ;color : #f60 ;} The above statements are respectively Defines the styles for "links, visited links, when the mouse is over, and when the mouse is clicked".
Text attribute:
This is different from the font attributes above. It involves typesetting: line spacing, character spacing, text decoration, etc., I have to Admit it, this is important.
Decorated hyperlink:
This is a relatively common CSS application. Yes, there are always so many hyperlinks on the page. The modification of hyperlinks is always very important.
a:link{font-weight : bold ;text-decoration : none ;color : #c00 ;}
a:active {font-weight : bold ;text-decoration : none ;color : #F90 ;}
The code below is very interesting, you can click here to see its effect
Class element (スa:), the foreground color attribute and text decoration attribute are defined in curly brackets,
The 'font-size' attribute is added to hover to change the font when the mouse activates the link*//
a:link {color: green; text-decoration: none}
//*The state when not visited, the color is green (green), the text decoration attribute (text-decoration) value
is none (none)*//
a:visited{color:red;text-decoration:none}
//*The visited state, the color is red (red), and the text decoration attribute value is none*//
a:hover {color: blue; text-decoration: overline; font-size: 20pt}
//* When the mouse is activated, the color is blue (blue), and the text decoration attribute value is overline,
The font size is 20pt*//
-->
/ /*Add a link, display three different states, and define the font and size of the link text*//
> ;
This example was copied from Hongen Online, Tutuo did it before After this kind of bang-dong, I copied a large section of js code.
So creativity and imagination are very important in many cases.
容器属性:虾米是容器?驼驼到现在还没找到一个定律一样的解释。8过,凭经验,<body></body><div></div>、<tr></tr>......类似的标签都是容器。这些标签就像容器,
罐装了我们的网页内容。使他们能在正确的位置来体现。CSS的容器属性包括边距、填充距、边框和宽度、高度、浮动、清除等属性
<pre class="sycode" name="code">边距属性
例:body{margin:1em 2em 3em 4em} //*定义文本的上、右、下、左的边距分别为1、2、3、4em*//
填充距属性
例:padding:1em 2em 3em 4em
边框属性
看上去很多,实际用起来很方便。
例:P{border:5px double purple}//*定义了四条边框为一样的值*//
图文混排
img{margin-right:2em;float:left}//*定义图片的右边距为2em,图片浮动在文字的左边*//
鼠标属性
在CSS当中,这种样式是通过“cursor”属性来实现的。Cursor属性有很多的属性值,
我们来看一下它的详细列表
例子:<span style=“cursor:hand”>手的形状</span>

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
