Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the reasons for the invalidity of CSS in web layout

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today Xiaobian to share with you the reasons for CSS invalid web page layout what are the relevant knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you read this article after some harvest, let's learn about it together.

Don't worry about validator warnings: If the validator says it found 12 errors and 83 warnings, ignore it and proceed to the next step.

Correct one error at a time: Work in sequence, from top to bottom, correcting one error at a time. HTML is browsed from top to bottom, and these errors are displayed in the same order.

Refresh the code every time you fix it to make it work again: A small error can often lead to a whole page of errors later. Therefore, if it is not properly handled,"fixing errors" may also lead to more errors. Revalidate the code after each correction, ensuring that the problem is completely resolved.

With these basic exceptions in mind, let's look at a few reasons why layout design is invalid.

1. div? Label not closed

This is one of the most common causes of layout failure. We are always surprised to learn how many elaborate design failures this is responsible for. An open div tag is one of the most common design mistakes in a forum, and one of the most difficult to diagnose. The validator sometimes points to the wrong open div tag, making diagnosis like finding a needle in a haystack.

Second, the troublesome embbed label

In the early 1990s, Microsoft and Netscape browsers began to recognize non-standard unique fonts. Unfortunately, this means that the W3C validator does not yet recognize certain critical HTML? Labels, such as "embed," even if they are already widely used. If you really want strict DOCTYPE validation, you have to drop nesting.

If you want to work with both layout and embedded media, try Flash? Satay method.

III. Improper DOCTYPE Statement

Not declaring DOCTYPE, or incorrectly declaring DOCTYPE at the beginning of a file, is also a common error. Based on general experience, Strict? DOCTYPE is the most advanced certification that everyone pursues. Strict? Validation indicates that your web page will be displayed optimally across all browsers. For declarations of DTD document types, you can refer to the related article at 52CSS.com.

IV. End slash

If your site doesn't validate, chances are you missed a trailing slash somewhere in your code. It's easy to ignore things like trailing slashes, especially in elements like image tags.

This is invalid in strict DOCTYPE. To fix this, add "/" to the end of the img tag.

V. Align label

If DOCTYPE is set to Transitional, you will use the "align" tag, but if you want to be strict, you will see a lot of errors. Align is another label that is not available for layout. Try using "float" or "text-align" instead of aligning conversion elements.

VI. JavaScript

What if you already declared Strict? DOCTYPE, you need to override the CDATA tag in JavaScript. This aspect of the verification process stumbles many programmers because websites tend to use embedded authentication for ads and tracking scripts. JavaScript。If JavaScript must be used, you can add the following tags around it:

VII. Images need the "alt" attribute

In case you haven't noticed, images are also a potential stumbling block to advanced verification. In addition to trailing slashes, advanced validation also requires alt tags to describe images, such as alt=? "Scary? vampire? picture"。

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

VIII. Unknown Entity Data

Entity data is another fallible problem that affects validation. We could consider replacing symbols such as ampersand with appropriate coded characters. entire? The list lists the appropriate encoded character entity data available in XHTML block designs.

IX. Bad nesting

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

X. Lack of "title" label

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

The above is "What are the reasons for CSS invalid in web page layout" All the contents of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report