• The following div is around every post. The class names for posts however are different. Here is an example of one of the div’s on my site. Can class names contain whitespace like the one for the div below? And usually aren’t class names a lot shorter. I looked in the style.css file to see if this class name existed and it does not. Where in the style.css stylesheet would i be able to customize the css for the div’s around posts?

    Example Div Tag:

    <div id="post-137" class="post-137 post type-post status-publish format-standard hentry category-textonly tag-high-funny">

Viewing 3 replies - 1 through 3 (of 3 total)
  • Elements in CSS can have multiple classes–and they are indeed separated by whitespace. It just makes it easier to style things and to apply the exact formatting to any particular element but without having to create a whole new style for that element. Using the example you posted, your div is going to be styled according to the CSS rules from each of the classes attached to it, ie. “post-137”, “post”, “type-post”, etc. etc.

    To customize those classes, all you have to do is just manually add them to your stylesheet. For example, if you want all of your posts to look the same, define a CSS rule using a class that is common to all of the posts:

    .post {
        margin-top: 10px;
        font-weight: bold;
    }

    Now all of your divs with a “.post” class will have a top margin of 10px and the text will be bolded.

    This is my basic understanding of it, anyway…hopefully someone else will be able to shine more light on the subject. Additionally, you might want to do a Google search for “multiple CSS classes” or something along those lines…there’s lots of good reading out there.

    Thread Starter lawloretienne

    (@lawloretienne)

    Thanks for the quick response. I was not aware that you could use multiple classes for one element. It looks like only some of the classes in the div have been defined in the style sheet. Maybe these classes are just created dynamically in the php and it is up to the dev if they want to define classes in the .css file.

    Maybe these classes are just created dynamically in the php and it is up to the dev if they want to define classes in the .css file.

    Bingo! That’s exactly it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘div post class name explanation’ is closed to new replies.