Common Cascading Stylesheet Mistakes
Cascading Stylesheet or CSS is one of the most used and convenient ways of coding the markup languages. Most of the websites are built on an HTML platform and hence it is important for us that the CSS is also correctly applied so that the information that the website wants to transmit to its viewers is correct. But, designers often commit fundamental mistakes that can make things go terribly wrong for a website.
You don’t waste bytes by adding units such as px, pt, em, etc when the value is zero. The only reason to do so is when you want to change the value quickly, later on, otherwise declaring the unit is meaningless. Zero pixels is the same as zero points. In order to get the accurate choice of the color, you must specify the hex code rather than writing the color in plain English. Never forget to add hash “#” at the start of the code so that it can be parsed correctly. Otherwise, you will have to remember to add another hash to prevent errors.
Unless you are likely to be changing your code much, avoid using several lines when only one line can serve your purpose. For example, when setting borders, some people set each side separately when each border is the same. So condensing the code is required here. It is okay to style the same element twice if it means avoiding the repetition mentioned in the point above. For example, let’s say you have an element where only the left border is different. Instead of writing out each border using four lines, just use two.
Space in code
But sometimes designers like to waste a lot of space in their code, by using plenty of unnecessary line-breaks or spaces before and after the code. It’ll only make the stylesheet bigger, meaning it’ll cost you more in the long run, as your bandwidth usage will be higher. Of course, it’s wise to leave some space in to keep it readable, though some people like to condense everything, leaving no space at all.
Designers must be careful about some common mistakes so that they can design the web pages in a proper manner and convey the message to its reader correctly.