• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Ginger Coolidge

Delivering WordPress Solutions

  • Home
  • Solutions
  • Blog
  • Gear
  • About
  • Contact

Styling with Class in WordPress

Published: November 28, 2016 - Updated: March 20, 2022

female model looking over a feather boa with bold eyes

Use the Power of Classes in CSS To Target Specific Page Elements

Recently I decided to spiff up the look of my About page. At the top were two square thumbnail images side-by-side – kinda plain. I decided I wanted to show larger images, make them circular, and make sure they looked good on mobile. This was crucial. I advertise that I build web sites. If a potential client is browsing my web site on an iPhone, and my About page looks disjointed, why would they hire me?

view of old About page in this website

Add Some Class

I started by inserting the images from the Media Library, however, attempting to target them for specific styling wasn’t working. To solve this, I created a new class and as part of that, set the URL for the image I wanted on the background property. Also in the class I’ve set the border-radius to create the circular shape and additional properties for height, width, etc.

https://gist.github.com/gspice/22867ca412527331c0581a25ba097308

How To Use It

So now that the properties are set, how do I use it? Easy!

<div class="img-circular-about-us-1"></div>

Seriously, that is it. You can place that div into the Text editor of a page, post or even a text widget. It almost acts like a short code. Hat tip to Jackie D’Elia who first shared this with me when creating the initial design for a previous site.

screen shot of this website's about page after changes

What About Mobile?

So now the larger images on the page looked great! That is until I viewed them on mobile. Ick — on mobile phones especially, the circles were not centered which occasionally left random amounts of text on either side. Worse, the different phone sizes caused the circular images to be stretched tall or squished wide. In looking at the mobile screen sizes, I noticed the first breakpoint in my Utility Pro starter theme is 320px wide which is the iPhone 4/5 width. The next breakpoint isn’t until 480px wide. This leaves a large gap for the latest iPhone 6/7 (375px) and iPhone 6/7 Plus screen sizes (414px).

In this case I decided to create two new breakpoints to accommodate both of the latest iPhone’s screen sizes. In my opinion, even if I only use these for this one class, it’s still worth it.

https://gist.github.com/gspice/13fe7f65acc07198e6c823e7c53ccb7c

this website's About page on iPhone 6-7 and Plus

Other Uses for Classes

The beauty about using a class is you can apply a completely different look to an HTML element that is already defined. For example, say you created a landing page for a promotion and you wanted the headings and anchor tags (links) to look very different from your main site.

To accomplish this, in your CSS you’d create new classes like .wacky-heading{css} and .wacky-links{css}. Next, in your page content, instead of <h2>My Wacky Heading</h2> you’d change it to <h2 class="wacky-heading">My Wacky Heading</h2>. For anchor tags you add the class like this: <a href="http://www.example.com" class="wacky-links">this text is linked</a> and it would pick up your new styling properties in the classes you created.

Pretty cool, huh?

Filed Under: Tutorials Tagged With: classes, css, WordPress

About Ginger Coolidge

I'm here to offer quality, clean-reading websites using WordPress that can serve you for the long haul. If you're not sure where to start, you're in the right place!   About Me

Reader Interactions

Share your thoughts... Cancel reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

*I use affiliate links sprinkled throughout this site. If your click results in a sale, at no cost to you, I may earn a small commission.
To see a full list, go here to learn more.


© 2025 · All Rights Reserved · GSC Solutions LLC · Proudly Powered by WordPress & hosted on Rocket.net