东莞市瑞成网络科技有限公司
 
 
Ten common reasons why CSS is invalid in Div+CSS web page layout
time:2020-09-28 03:20:18

Issues that need attention when W3C verifies the program. 


1. Don't worry about the warning of the verification program: If the verification program says that it found 12 errors and 83 warnings, ignore it and continue to the next step. 

2. Correct one error at a time: work in sequence, from top to bottom, one error at a time. HTML is viewed from top to bottom with a browser, and these errors are displayed in the same order. 

3. Refresh the code every time you modify the code to make them effective again: a small error often leads to a series of errors for the entire page. Therefore, if the operation is improper, "correction errors" may also cause more errors. Make the code effective again after each revision, so that you can ensure that the problem is completely resolved.

Knowing the basic abnormalities above, let's take a look at several reasons why the layout is invalid.


1. The div tag is not closed

This is one of the most common reasons for layout failure. When we learn how many exquisite section designs are the culprit, we will always be surprised. The opened div tag is one of the most common section design errors and one of the most difficult to diagnose. The verification program sometimes points to the wrong opening of the div tag, and the diagnosis is as troublesome as finding a needle in a haystack.


Two, troublesome embed tags

In the early nineties, Microsoft and Netscape browsers began to recognize non-standard unique fonts. Unfortunately, this means that the W3C verifier has not yet recognized certain key HTML tags, such as "embed", even though these tags have been widely used. If you really want to get strict DOCTYPE (document type) verification, you can only give up nesting.

If you want effective layout and embedded media at the same time, you can try the Flash Satay method.


3. Improper DOCTYPE declaration

It is also a common mistake not to declare DOCTYPE, or to declare DOCTYPE incorrectly at the beginning of the file. According to general experience, Strict DOCTYPE is the highest level of verification that everyone pursues. Strict validation shows that your web pages can be best displayed on all browsers.


Fourth, the trailing slash

If your website cannot be verified, it is likely that you missed the trailing slash somewhere in the code. It is easy to ignore things like trailing slashes, especially in elements such as image tags.

This is invalid in strict DOCTYPE. To solve this problem, add "/" at the end of the img tag.


Five, Align label

If the DOCTYPE is set to Transitional, you will use the "align" tag, but if the requirements are higher and you want to get Strict verification, you will see many errors. Align is another label that cannot be used for layout design. You can try to use "float" or "text-align" instead of the align conversion element.


Six, JavaScript

If Strict DOCTYPE has been declared, you need to override the CDATA tag in JavaScript. This aspect of the verification program has baffled many programmers because websites tend to use embedded JavaScript for advertising and tracking scripts. If you must use JavaScript, you can add the following tags before and after it:


Seven, the image needs "alt" attribute

You may not have noticed that images are also a potential stumbling block for advanced verification. In addition to the trailing slash, advanced verification also requires alt tags to describe the image, such as alt= "Scary vampire picture".

Search engines also rely on alt tags to identify images on web pages, so it is always good to add alt tags anyway.


8. Unknown entity data

Entity data is another easy error that affects verification. We can consider replacing symbols such as "&" with appropriate coded characters. The entire list lists the appropriate encoded character entity data available in the XHTML section design.


Nine, bad nesting

Nesting means that the elements are included in the element, and it is easy to confuse the order of nested elements. For example, start the strong tag before the div tag, but then close the div tag first. This may not change the section layout, but it will invalidate your section design.


10. Missing "title" tag

Although this seems to be an obvious mistake, many programmers (including myself) often miss the title tag in the "head" section. When you see "missing a required sub-element of HEAD" (missing a required sub-element of HEAD), you will find that you forgot to add the title tag.


 
Next:最后一页

Contact us

Mr. Kwong 13728355187
Miss Chen 13538439192
Email: 635187556@qq.com
Wechat QR code
Copyright © 2019-2020 Dongguan Ruicheng Network Technology Co., Ltd All rights reserved.  XML  Address: Room 605, Junda Commercial Center, Guancheng District, Dongguan City