CSS Mistakes in WordPress Theme Development that you must Avoid

November 13, 2015 Vinay Wordpress, Wordpress theme

 CSS Mistakes

The widespread popularity of WordPress has made the evolution of new themes every now and then quite common. Also, the ease of use of this content management system makes it very convenient to experiment with look and feel of any site. However, many developers and website owners still make numerous mistakes while writing the CSS for WordPress themes.

Since browsers are unable to understand these mistakes and thus respond casually by producing a frayed appearance. It is extremely important to handle these mistakes at the earliest since these errors can lead to broken websites. Therefore, we have put together some of the common goofs that even professionals make.

  1. Overlooking ground rules for CSS

CSS is one great way of designing an attractive look for your website. However, there are certain principles for styling the cascading sheets, which must be followed to obtain right results. For an instance, a class or an ID should be recognized as a class or an ID except for the HTML tags. Also, every selector needs to follow a particular syntax as mentioned below:

Selector {property: value; property: value; }

  1. Adding unnecessary code

This is a common mistake made by many developers and designers when it comes to designing a webpage with CSS. Though every designer has its own way of writing the code, it is important to avoid unnecessary coding. Amending redundant codes not only make your theme look shabby but also affect its functionality.

Example: selector { property: value; property: value; }

Correct way

.some-title, .some-other-title{font-weight:bold;}

Incorrect way

.some-title { font-weight: bold; }
.some-other-title { font-weight: bold; color: red }

  1. Incorrect placement of the files

Yes, there is a right way of placing the CSS files in WordPress failure of which can break down the theme or the website. CSS files are usually placed in style.css file which is present within the selected theme folder. You can find the PHP files in the theme folder, and HTML code in the Index.php. Since PHP files are responsible for showing the changes you’ve made in the style.css file, you can easily make changes in the specific CSS tags in PHP files instead of HTML files.

  1. Using wrong template module

Though the modular templates are quite handy and easy to use, there are times when developers make errors while tweaking them by making modification in the wrong file. Developers tend to make changes in the content-page.php file instead of content.php. Therefore, it is always recommended to be extra careful when making modification in the template module section.

  1. Multiple choices to a single selector

It is yet another common error done by many developers. Assigning multiple choices to a selector can build conflicts between different selectors. Also, the multiple choices option makes it difficult to choose one particular selector.

  1. Spelling mistakes

It is one of the most common mistakes made by developers. Spelling vital terms incorrectly while writing the code in the style sheet can fail to load the expected results on the browser. As an example, instead of using 10px, writing 10pc can lead to unnecessary errors in the entire web page.

We’ve all been there. Whether you tend to commit small mistakes or bigger ones, they can lead to failures in many ways. We have compiled this list in a hope to help you write better CSS coding without making any mistakes.