search
HomeWeb Front-endHTML Tutorial来说说比较一个那位的方法是最高效的:当页面因html标签错误(少/多/错匹配)而错乱时_html/css_WEB-ITnose

HTML 布局 标签 错乱

不说简单的页面.
起码页面上几k行.
全部布局几乎全部使用了最复杂的:浮动,绝对定位,相对定位,div....;多列,多行,错行
错误情况比较复杂,多处错乱;


那么你会怎么解决?步骤怎么样,用到什么工具?
解决最乱的是什么情况,速度如何?
你觉得这种情况你最想说点什么?

回复讨论(解决方案)

面试题?

重写最简单直接

这个怎么没有人关注呢?
在某个php群中讨论时,曾经有人跟我说,此类问题,最长10分钟,否则此人应该下岗;
可是我不相信,问过他是否清楚解决步骤.

我曾经试过dw,ie,ch,firefox,phpstorm;
phpstorm在这块的处理还是不错的,能明了的了解到多余的标签,且可以折叠.
但是同样,有些人为认为是错误,它还是不会提示.
firefox的查看源代码中也能与红色高亮的显示无效的标签,但是像

之类问题一样认为正常.
目前我还没有发现有快速的解决方案.问过一个前台同事,他的处理是折叠查看丢失的标签.+扣工资;

此类问题极易出现,尤其是多人多岗位合作一个页面的情况下,再加上部分不了解标签代码的人;再加上布局是浮动性的,此问题尤其突出,且解决难度会很大.
但是对于布局简单的页面,此类错误影响非常小,可以从qq.com这类首页即可看出存在很错误标签,但并不影响浏览器排版,浏览器会尽最大的兼容性来解析不规范标签..

如果有工具能快速提示错误问题,这类问题解决效率会高很多.

我记得firefox有个插件专门校验标签的匹配,比查看源代码略为高级。

我首先会用一些格式化工具将HTML文档进行格式化,
为的是以最佳的缩进效果显示。

如果有错误,工具有时候会提示,
但有时候有错误却不会提示,这时候可以看看缩进是否整齐来查找错误。

还有就是把页面的DOCTYPE设置为xhtml严格模式,
这样如果有错误的话,验证工具会尽可能多地给出错误提示。

最后,如果工具仍不能找出错误,只有自己逐行并纵观全局排除。

回5楼:如果是解析后的对于此问题并没有太大帮助;
回6楼:折叠+全局纵观是一个非常耗时的,且经我测试,firefox中并没有提示某个div是多余的,但是dw中却会提示是多余的.但是从查看源代码来看,这并不会出现js补全的可能,另强制模式(我是这样加,nbsp;html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">)好像并没有起到太多作用;

如我们的网站首页非常大.1600行,


如果按照dw中的提示,那块出现问题,查找就有点郁闷了.目前我并没有实际的去折叠查找这个dw中的提示,是不是真实的存在,没有但是firefox中却没有提示.所以,我目前不能确定dw是正确的firefox是错误的.
前台也不是我在负责,
出现这样的问题,比较麻烦.
那位还有更加好的方式?

最常用的工具就是tidy

<html><body><p>kdkkdkdkk<p><div>kkkkk</p></body></html>


使用tidy处理后
C:\Users\Administrator\Desktop>tidy s.htmline 1 column 1 - Warning: missing <!DOCTYPE> declarationline 8 column 1 - Warning: inserting implicit <p>line 6 column 1 - Warning: missing </div>line 2 column 1 - Warning: inserting missing 'title' elementline 5 column 1 - Warning: trimming empty <p>line 8 column 1 - Warning: trimming empty <p>Info: Document content looks like HTML56 warnings, 0 errors were found!<!DOCTYPE html><html><head><meta name="generator" content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39"><title></title></head><body><p>kdkkdkdkk</p><div>kkkkk</div></body></html>About this fork of Tidy: http://w3c.github.com/tidy-html5/Bug reports and comments: https://github.com/w3c/tidy-html5/issues/Or send questions and comments to html-tidy@w3.orgLatest HTML specification: http://dev.w3.org/html5/spec-author-view/HTML language reference: http://dev.w3.org/html5/markup/Validate your HTML5 documents: http://validator.w3.org/nu/Lobby your company to join the W3C: http://www.w3.org/ConsortiumC:\Users\Administrator\Desktop>


所以这个东西,自动化处理并不能解决这个问题.

补充说:这个工具更多的用处是对于优化方面,而非处理这个问题.否则如果只是简单的删除了,可能出现的问题更加严重.

拙见,感觉没必要99%的遵守规定,规定是死的,只要界面效果到达了,代码也相对简洁了,不就行了,

你理解错了,我问的是标签出错了,乱时,怎么尽快修正.
对于大的页面,重写不现象,功能得重新弄.
修正是比较好的方式,但是我现在能想到的修改步骤并不高效.
征一高效解决此问题方法而已.
跟html是否漂亮无关.

tidy有多种用法的,也有很多工具借用了它
你只想到用它来修正这个并不是最好的用法

对于你给出的例子,tidy修正处理的结果并没有错的,但不是你所期望的,这就是个问题??电脑只会按某种固定的方式去思考问题,但人不是

所以你应该使用具有tidy插件的编辑工具,去 提醒你不合规范的地方,由你按自己的思想去修正(要实现自己的期望就自写程序),而不是图省事直接交给tidy修正

看来没有省事的方法了?

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

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

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.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)