Common mistakes are made when applying DIV CSS coding
This article describes some of the mistakes that are easy to make when applying DIV CSS coding. DIV CSS is one of the commonly used terms in website standards (or "WEB standards") One, usually to illustrate the difference from the table positioning method in the HTML web design language.
Some mistakes that are easy to make when applying DIV CSS coding
DIV CSS is one of the commonly used terms in website standards (or "WEB standards"), usually to describe the relationship with HTML web design language The difference between the table positioning methods in XHTML website design standards is that table positioning technology is no longer used, but CSS DIV is used to achieve various positioning. It's easy to make some mistakes when using DIV CSS coding. This article lists some common mistakes:
1. Check whether the HTML elements have spelling errors or forget the closing tag
Even veterans often make mistakes in the nesting relationship of DIVs. You can use Dreamweaver's verification function to check for errors.
2. Check whether the CSS is correct
Check whether there are spelling errors, whether you forgot the ending }, etc. You can use CleanCSS to check DIV CSS for spelling errors. CleanCSS is a tool to reduce weight for CSS, but it can also check for spelling errors.
3. Determine where the error occurred
If the error affects the overall layout, you can delete DIV blocks one by one until the display returns to normal after deleting a DIV block, then you can determine where the error occurred. Location.
4. Use the border attribute to determine the layout characteristics of the error element
Using the float attribute for layout may cause errors accidentally. At this time, add the border attribute to the element to determine the element boundary, and the cause of the error will be revealed.
5. The parent element of the float element in DIV CSS cannot specify the clear attribute
If the clear attribute is used on the parent element of the float element under MacIE, the layout of the surrounding float elements will be confused. This is a famous bug of MacIE. If you don't know it, you will take detours.
6. Float elements must specify the width attribute
Many browsers have bugs when displaying float elements without specified width. So regardless of the content of the float element, the width attribute must be specified for it.
In addition, when specifying elements, try to use em instead of px as the unit.
7. Float elements cannot specify attributes such as margin and padding
IE has a bug when displaying float elements with margin and padding specified. Therefore, do not specify margin and padding attributes on float elements (you can nest a DIV inside the float element to set margin and padding). You can also use hacks to specify special values for IE.
8. The sum of the widths of float elements must be less than 100%
If the sum of the widths of float elements is exactly 100%, some ancient browsers will not display properly. Therefore, please ensure that the sum of the widths is less than 99%.
9. Is the default style reset in DIV CSS?
Some attributes such as margin, padding, etc., will be interpreted differently by different browsers. Therefore, it is best to set all margin and padding to 0, list style to none, etc. before development.