Support » Fixing WordPress » Having A Different Style for the FIrst paragraph

  • Hello WordPressers!

    I wish to incorporate a hierarchy of font-sizes in my posts. I would like to have the first paragraph be a completely different style from the rest of the post.

    The only workaround I have discovered is to create an excerpt and use both the_excerpt and the_content tags. Unfortunately, I may not plan to use this type of styling on future installments of my creative website. I would like this to be php-triggered instead of database manipulated if that makes sense.

    Any help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • What I’d do is create a class for the first paragraph. For instance, in your stylesheet do something like:

    .firstparagraph {
    color:red;
    font-family:arial;
    font-size:15px;
    }

    Then when you write a post you’d just wrap the first paragraph in a div like so…

    <div class=”firstparagraph”>blah blah blah blah blah. blah blah blah. blah blah blah blah blah. blah blah blah. blah blah blah blah blah. blah blah blah. blah blah blah blah blah. blah blah blah.</div>

    A more elegant solution that will not interfere with any tags generated by wordpress and that doesn’t require any work when writing the posts would be simply adding this to your stylesheet:

    .your-post-class-here > p:first-child {
    	color: red;
    	}

    This example would for instance make every first paragraph red.
    Cheers.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Having A Different Style for the FIrst paragraph’ is closed to new replies.