Styling the WordPress Comments Box

This tutorial walks you through how to style the Wordpress Comments Box.

The wordpress comments box is standard with most WordPress themes for posts. It can be a great way to communicate with visitors to your website.

However with many themes it often comes styled in one specific style or left in the basic WordPress style. This can be okay depending on your site but if you’ve got a heavily specific and well designed site not having the comments box styled in a similar manner can look a little strange.

So firstly let’s start with the title of the box which by default is ‘comments’.

We can add CSS to this by using the selector:

.comment-form-comment label {

Font-size: 40px;

}

With the above code we’re setting a font size of 40px for the ‘comments’ text.

To change the text from comments to something else there are a few ways that we can do this but we’ll explore two of the easiest.

1. Using a translation plugin – There are many language translation plugins available to use with WordPress which will allow you to translate the core site text rather than having to write any code on your pages / posts.

2. Using jQuery – This method involves using some code take a look at our adding jQuery to WordPress tutorial to learn how to add it to your site.

The code:

By using text() we can change the text for the comments to whatever we want it to be. For example:

<script>

$(“.comment-form-comment label”).text(“Comments Box”);

</script>

 Next let’s look at styling the main comments text box.

To do this we’ll use the selector: 

#comments .comment-form-comment textarea

This allows us to add code directly to the comments box within the comments form. For example:

#comments .comment-form-comment textarea {

border: 1px solid orange;

}

This sets the border of the comments box to orange, you can set it to any colour and weight using the above code.

You can style this box in a tonne of different ways for example setting the background colour of the whole box:

 #comments .comment-form-comment textarea {

background-color: orange;

}

Styling the submit button is also pretty easy for example:

#comments p.form-submit #submit

This basically gets the submit button via #submit within the form. So if you’re styling it an example would be: 

#comments p.form-submit #submit {

Background-color: orange;

}

Using some of the code demonstrated above you can also add a background to the div that contains the button for example:

#comments p.form-submit {

Background-color: orange;

}

Using the above classes you can also style the fonts within each section an example of this would be:

#commentform h3 {

font-family: ‘montserrat’;
font-weight: 28px;

}

The above styles any h3 sections within the overall comments form. You can set this for any standard class e.g. p, h1,h2,h3,h4,h5 etc.

Further reading:

Reducing WordPress comments spam

We hope this provides you with an idea of getting started with styling the WordPress comments form with CSS. We’d appreciate a share or any comments if you found this useful, thanks!

Tech Typed
Tech Typed
Articles: 186

Leave a Reply

Your email address will not be published. Required fields are marked *