search
HomeWeb Front-endHTML Tutorial写css的细节问题以及搜寻文档问题_html/css_WEB-ITnose

这是我在css控制字体属性所犯的一个错误,可以说是疏忽大意。

题目要求如图:

虽说这题很简单,但是我个人还是做错了,我个人。我先把我之前错误的html代码和正确的css打一遍

错误的1.html

<html><head><title>font</title><link rel="stylesheet" type="text/css" href="one.css">    <!--对css的引用这是外联css--></head><body><span class="s1">梁山英雄排行榜</span><br/><br/>      <!--"<span></span>是行元素,而<p></p>是块元素"--><span class="s2">宋江</span><br/><br/>               <!--class定义css的类别--><span class="s3">卢员外</span><br/><br/><span class="s4">吴用</p><br/><br/>                   <!--请注意</p>接下来就是我要讲的,错也错在</p>这--><span class="s3">豹子头</p><br/><br/><span class="s3">大刀关胜</span><br/><br/></body></html>

正确的one.css

.s1{   color:gold;   font-size:30px;}.s2{   color:red;   background-color:silver;   font-style:italic;}.s3{  background-color:silver;   }.s4{   background-color:silver;     /*silver为银灰色*/   font-decoration:underline;   /*decoration为修饰,underline为下划线*/   font-style:italic;           /*字体样式为斜体*/}

结果与实际大相近庭如图:

我的非常不好的想法:首先我本来注意到

的,但是我先把它放在一边,先写完css再说,当写完css我便忘记了更改html中的标签了。

后果:我们看到段落之间差距很大,都出现了下划线,我粗略看了下代码还是没发现

琢磨是不是优先级问题,但是走偏了跑题了,改css也不太对,问群里也没什么答案,甚至起类名连着父子选择器都来了,百度也没好结果,我反思了一阵子。

后来:重看一遍html代码发现了

的问题,然后进行了一下总结

究其原因(个人总结):还是并没有将“吴用”“豹子头"给包起来虽然将"大刀关胜包起来"并没有什么用,因为问题的起始标签是从"吴用"这开始的到"大刀关胜"结束,也就是他们三者成了一个共同的整体,而后css的类名不一样就造成了优先级问题的冲突。个人觉得这有点像是内存溢出一样。而后我将"吴用"“豹子头”"大刀关胜"换成将其包起来

<html><head><title>font</title><link rel="stylesheet" type="text/css" href="one.css">  </head><body><span class="s1">梁山英雄排行榜</span><br/><br/>     <span class="s2">宋江</span><br/><br/><span class="s3">卢员外</span><br/><br/><span class="s4">吴用</span><br/><br/>       <span class="s3">豹子头</span><br/><br/><span class="s3">大刀关胜</span><br/><br/></body></html>

结果如图显示正常:

我把这图贴到这,方便观看,还有个练习二我把正确的html代码和遗漏的css也一起写一遍

2.html

<html><head><title>链接</title><style="text/css">            <!--内联css,不过css的注释是"/**/"-->a{    color:red;    font-size:24px;    font-decoration:none;}a:hover{                    <!--hover为伪类定义鼠标悬停的-->   font-decoration:underline;   font-size:40px;   color:green;}<head><body><a href="#">连接到百度<a></body></html>

你想一下代码哪里遗漏了和遗漏的代码是什么写的?最好不用百度或是文档,不要看下面的补充,先想一想比较好,我把我的经验和想法分享一下吧:我自己遗漏的我也百度了词条"css能定义字体的属性",但是我事后一想css文档手册有的东西为什么百度呢?这样就显得自己很不专业。

完整的补充:

<html><head><title>链接</title><style="text/css">           a{    color:red;    font-size:24px;    font-family:"华文新魏";    font-decoration:none;}a:hover{                      font-decoration:underline;   font-size:40px;   color:green;   font-famliy:"宋体";}a:visited{color:gray;}<head><body><a href="#">连接到百度</a></body></html>

如图:

注:记得再次打开html此链接时,先清除浏览器缓存,不然效果和灰色的连接到百度一样的,刷新也没用。

个人归纳总结:遇到问题首先想的并不是解决问题,而是不要慌,不要马上去百度和问群里,即使解决了印象也不深,以后估计还是这样,那就不好了;我还是建议多看文档信息,先定位大致的位置然后再一个一个去查询。然后考虑它错误效果和报错因素,再仔细看一遍代码发现有遗漏和错误没有,要有逻辑性的思考问题;然后再解决问题。之后再总结一下,加强印象。

ps:

个人认为吧:百度是最好的答案,同时也是最差的,它少了自己思考的过程和只想一味的索取,最新的技术,是很少能够百度到的,百度也不是万能的,而万能的正是自己。

虽然我不是个编程大神,经过我的学习我认为是这样理解的:帮助人解决问题,还不如让他思考和分析问题的思路,知其然也所以然,授人以鱼不如授人以渔。

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
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.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

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.

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

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

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.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.