OneBite.Dev - Coding blog in a bite size

edit css in wordpress

Code snippet for how to edit css in wordpress with sample and detail explanation

Adding custom CSS in WordPress is an easy way to enhance the visual appeal of your website and make it more distinctive. Here’s a straightforward guide on how you can set about doing that.

Creating a custom CSS in WordPress

Below is a simple CSS code that you can use as an example.

.site-header {
    background-color: #f1f1f1;
    padding: 20px 0;
}
.site-title a {
    color: #333;
    font-size: 25px;
    text-decoration: none;
}
.site-description {
    color: #888;
    font-size: 15px;
}

Code Explanation for creating a custom CSS in WordPress

Now, let’s break down what each part of the code does:

  • .site-header {...}: This code block styles the header of your site. The background color is set to a light shade of gray (#f1f1f1), and padding is added to the top and bottom (20px 0).

  • .site-title a {...}: This part of the code targets the site’s title. The color of the title text is dark gray (#333), the font size is 25px, and there are no underlines (text-decoration: none).

  • .site-description {...}: This last block styles the site description. The color of the description text is made lighter (#888) to distinguish it from the site’s title, and the font size is set to 15px.

To implement these changes, you need to paste the code above into the ‘Additional CSS’ section in the WordPress Customizer. To access this:

  1. Log in to your WordPress dashboard
  2. Go to ‘Appearance’
  3. Click on ‘Customize’
  4. Then go to ‘Additional CSS’.

Once you paste the code, you will see the changes live. Press ‘Publish’ for the changes to take effect.

Happy coding!

css