Magazine for designers and web developers
Collect

7 Top mistakes you make while writing CSS for WordPress theme

Article by jackcalder in Web Design -

With a plethora of themes available for your WP site, experimenting with the look and feel of your website won't be a daunting task anymore. Just get on with choosing a suitable theme for your WP site and you can kickstart your journey by making the most of everything that the blogging-cum-web development platform has in store for you. One of the best aspects associated with WordPress is the ease of customizing a theme in accordance to your specific needs and expectations. And that's not all. You just have to moderate your theme's CSS to make this happen. In today's post, I'll be introducing you to some of the most common mistakes which are being made by novice and professional WordPress developers during the CSS moderation process. I'm sure an in-depth insight into these mistakes will help you gear up for an extremely exciting WP theme customization venture.

What does WordPress Theme Customization actually refer to?

Before looking at the mistakes made during CSS moderation, it is important for you to understand what exactly WordPress Theme Customization refers to. Well, customizing a WordPress theme is directly related to writing the CSS. As the very first step, you simply initiate the custom file editor, build all the required changes and finally save the modifications. It is primarily during the process of initiating the changes that the majority of broken links tend to enter into the CSS, causing major bugs in the entire WordPress theme.

Now, let's look at the six common errors made by WordPress developers while customizing WP Theme via writing/modifying the CSS:

1. Ignoring the ground rules for Selectors

There are developers who tend to forget some vital ground rules for Selectors while writing the CSS for a WordPress theme. If you too are planning to tweak your theme's CSS for an enhanced look and feel, it is important for you to be familiar with the key details about selectors. Do remember every selector has an identifiable CLASS or ID excluding the HTML tags. Here is how you must define your selectors while writing the CSS:

{property: value; property:value;}
For instance, if you're interested in aligning the text right and assigning a blue color to the text, then the applicable selector rule would be similar to the one shown below:

p{
 text-align:right;
 color:blue;
}
 
Here, pay special attention to the proper placement of colons and semi-colons in addition to the open-close brackets.

2. Not paying heed to the browser bugs

Since different browsers will view your web pages differently, it is absolutely essential to adhere to all the CSS standards which need to be followed while writing the WordPress theme's CSS stylesheet. Here is a list of CSS issues which emerge as a result of not considering the browser-compatibility parameter while writing the CSS:

  • Text and links jump across the web page when the mouse is moved over a particular link
  • Text jumps all around the page as the user chooses to scroll down the current web page
  • Layouts don't appear consistent, when viewed using different browsers
  • All the extra effects incorporated within the WordPress theme aren't similar in appearance and often tend to vanish for certain browsers.

3. Spelling important terms wrong

Incorrectly spelling some vital terms used while writing CSS is a mistake every WordPress developer needs to pay attention to. For instance, using 10pc in place of 10px will lead to unwanted errors in the entire CSS stylesheet. Since it's quite easy to overlook some simple spelling flaws, I recommend using CSS Validators which will pick up on a wide range of incorrect spellings which have entered into your CSS stylesheet, either due to mere negligence or plain unawareness.

4. Working on a wrong template module

During WordPress theme customization, it is advisable to be extra careful about the template module section that you're trying to customize. There are situations when despite having the benefit of working on new modular templates, the WordPress developers tend to make the mistake of choosing an incorrect template module section. For instance, changing the template module comments.php in place of comments-popup.php will lead to unwanted results. A viable solution to this problem is to ensure a complete backup of your entire CSS stylesheet, which can later be restored when needed.

5. Having incorrect knowledge about file placement

As someone who is new to the world of CSS, it is an excellent idea to gain detailed understanding of file placement. You must know that all the CSS styles are included within the WP theme folder's style.css file with some PHP files also stored in the WP theme's folder. Also, you must know that HTML code for the theme is always included in the theme's index.php file. With a detailed insight into such and many more facts about file placement, it would be convenient for you to make changes to only the most appropriate CSS selector tags within the PHP files, without the need for touching the files.

6. Assigning single pieces of information to multiple references

Well, this is a mistake made out of habit. There are WordPress developers who opt for assigning a single piece of information to a range of references, confusing the CSS and resulting in various design errors. This is a scenario which mainly occurs each time you're using your own stylesheet instead of a new CSS stylesheet.

7. Things going wrong with the styling of the Blockquote element

When it comes to styling the Blockquote element, WordPress developers are bound to make some mistake or another. A simple solution to style the blockquote element is to add specific margins and use a non-regular font for enhancing the visual appeal of your WordPress theme. Using an eye-catching image for your background also works as a convenient means of enriching the entire WordPress blog/website.

Conclusion

With all said and done, here's hoping the above post will allow you to get a clearer picture about the key mistakes that tend to interfere with the smooth execution of a WordPress theme customization process. Taking each one of them seriously will undoubtedly aid you in modifying your WP theme like a pro.