search
HomeWeb Front-endHTML TutorialFirst introduction to CSS_html/css_WEB-ITnose

<strong> CSS全称Cascading Style Sheets,即级联样式表</strong>
<strong> CSS是一种表示文件样式的语言,也可以说是用户看到的界面,是一种真正能做到表现与内容的分离的语言</strong>
<strong> 一、基本语法</strong>
<strong> 规则:CSS规则主要由选择器以及一条或多条声明组成</strong>
<strong> 选择器:就是定义在代码段中的标签,用来作为CSS识别的标记</strong>
<strong> 声明就是要对选择器中的内容设置的格式</strong>
<strong> 实例:</strong>
<strong> 在代码段中设置选择器如下,Style用来标记文字“提高班”</strong>		
<pre class='brush:php;toolbar:false;'><strong> <div id="style">提高班</id></strong>
<strong> 那么在CSS中可以根据选择器来设置文字“提高班”的格式</strong>
<strong> #style{</strong>
 <strong>font-size:12px;</strong>
 <strong>text-decoration:underline;</strong>
<strong>  color:#fff;</strong>
<strong> 这样就可以设置文字“提高班”的字号,下划线和字体颜色了</strong>
<strong> 这样看来,CSS也体现了面向对象抽象的思想,把对文件的设置抽象出来,通过CSS语言来实现,从而减</strong>
<strong> 少了web代码的负担,而且在更在样式的时候也会很方便,可以通过对一类文件做好标记,统一修改即可。</strong>
<strong> 二、使用方法</strong>
<strong> 以上说的是CSS的基本语法,但是在具体使用样式表时会有多种方法,主要有一下方法</strong>
<strong> 1.外联式Linking:将网页链接到外部样式表</strong>
<strong> <link href="css/common.css" rel="stylesheet"></strong>
<strong> 这个样式就是牛腩在没词新建一个web层,首先要做的工作,就是公共样式表拖到新建的web中</strong>
<strong> 优点:当样式需要被用到很多页面的时候,可以通过外联式改变一个文件夹达到改变多个页面的效果</strong>
<strong> 2.内联式Inline:顾名思义,它就是内嵌到网页各个元素中</strong>
<strong> </strong><pre name="code" class="n"><p style="color: red; margin-left: 20px"> This is a paragraph </p>

<strong> 当网页中一些特殊的样式要应用到个别元素时就可以使用内嵌式,直接在代码中写即可</strong>
<strong> 3.嵌入式Embedding:在网页上穿件嵌入的样式表</strong>
<strong> </strong><pre name="code" class="n"><style type="text/css"> body {background-color: red} p {margin-left: 20px}</style>

<strong> 对单个文件嵌入特别的样式时可以用嵌入式样式表</strong>
<strong> 内联式和嵌入式区别</strong>
<strong> 个人认为两个最大的区别在于作用的范围不同,内联式是作用于个别元素而嵌入式作用于文件,两者</strong>
<strong> 的本质都是一样的,都是嵌入在网页中</strong>
<strong> 三、小结</strong>
<strong> CSS作为一种样式设计语言,它的精确度是非常高的,从牛腩中我们就可以发现,可以精确到单位像素</strong>
<strong> 而且它还几乎设置所有的文字样式,有很强的易读性</strong>
<strong> 以上只是CSS知识的九牛一毛,关于CSS的内容还有很多需要去学习,后续会有对选择器及CSS核心内容</strong>
<strong> 的总结</strong>
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
What is the difference between an HTML tag and an HTML attribute?What is the difference between an HTML tag and an HTML attribute?May 14, 2025 am 12:01 AM

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

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

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

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.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

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.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

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.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

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

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

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

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 Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),