Nothing is for sale here. Freewill tips keep the site running. Want to help? → Tip via Paypal

Generic CSS Classes

CSS allows you to create your own generic style classes. A generic class is simply a style rule that is not associated with a specific selector (CSS selector = HTML element).

It can be applied by adding the class name to a qualified selector. A qualified selector is any HTML element where it’s legal to use the style rules assigned by the generic class.

To create a generic rule, simply add a period and a class name to your embedded or external style sheet. For example:

.border {border: 1px solid black; padding: 7px;}

By creating that rule, anytime we add class="border" to a qualified element, that element will have a solid black 1 pixel border around it and 5 pixels of padding within the element.

Here’s an example of how to add that class to a division tag:

<div class="border">

Here’s what that class would look like:

My first house was huge, I had plenty of room to roam. But then I developed multiple personalities disorder and it got real crowded around there. Everywhere I’d go, there I was. I couldn’t stand it any longer, I needed help . . . so I bought an apartment complex. Now I each have my own unit and we get along with me much better.

OK, I cheated . . . I slipped in a background color and changed the font. Hey, you have to watch me, sometimes I’m a wild and crazy guy like that, even if I am an old coot! grinning emoji