8 Common mistakes in new handwriting css

Source: Internet
Author: User
Tags format
The great master will make such a mistake, because when the page structure is very complex, nested many layers, it is easy to throw off the tag.

Just contact CSS When more dazed, many times do not know how to start, how to do. Get an effect picture, a lot of questions, puzzle us, how to layout? Absolute positioning or relative positioning, choose what label? What kind of structure ... and so on. Of course, in the process of writing code, will encounter a lot of problems, especially our novice, on all aspects just not very understanding, more lack of experience, encountered problems often unprepared. I think that when we encounter problems, we should learn to sum up, to avoid the next encounter or make the same mistake.

Here is a summary of some of the mistakes you made in your work,

and solution tips want to be helpful for CSS novices.

First, check the HTML element for spelling errors, or forget to close the label

The great master will make such a mistake, because when the page structure is very complex, nested many layers, it is easy to throw off the tag. Especially like me, accustomed to writing in Notepad, it is more prone to error. So you must be careful when you write.

Second, check the CSS is correct

The most common common CSS error is that the attribute names in the style and HTML are inconsistent. Led to the writing of the style, but no effect.

Third, use background to find the corresponding layer

We debug errors, especially when debugging browser compatibility, the layer nesting more, prone to dislocation, overlap, this time to the key to add a few layers background color to show the difference. This helps to troubleshoot errors.

The elimination method determines the wrong position.

When we write CSS encoding, we usually do a little and then preview, if there is a mistake, we can delete the new layer, until the normal display, to determine the problem in the end of which layer.

Five, float element must specify the Width property

Many browsers have bugs when displaying float elements that do not specify a width. So regardless of the float element's content, be sure to specify the width property for it.

Vi. Removing duplicate styles

Many times we declare a common style in the head and then write it down and forget about it. For example, we have declared img{border:none at the beginning.

And then when I met the IMG tag, I wrote it again. Such a situation should be avoided.

Seven, note the encoding format

In general, we use the encoding format: gb2312 and UTF8 two kinds. There is no merit or disadvantage. But you can't mix it up. Many editors default to things UTF8 format.

Eight, the writing order of the link style

Many people write the link style, after clicking the color is not the result of their own, this time to check the link style of the written order. The correct writing order should be: L-v-h-a.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.