Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6655039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:27:51+00:00 2026-05-26T01:27:51+00:00

How do i make the first sentence in the last paragraph bold using css?

  • 0

How do i make the first sentence in the last paragraph bold using css? I also want to add extra padding to the top of this last paragraph so that it will wrap around an image. If I increase the padding on the bottom of the floated image, the paragraph does not wrap to the bottom flush left margin of the image, it just flows along the right of it — not what I want. I tied a class to the “p” element since I only want to effect the a certain paragraph (and I don’t see a “:last-child” pseudo-element nor do I know if you can use two pseudo-elements on one element or class).

#wf_mainContent_left p.last_wfp:first-line {
padding-top:20px;
font-weight:bold;
color:red;
}

HTML

<p class="last_wfp">This is the first sentence that I want bold and red. This is the second
 sentence that I don't want that treatment.</p>

This bolds both sentences when I only want the first sentence, even though they are on the same line. This should be able to be done according to this tutorial. And there is no effect on the padding. I’ve tried adding a <br> tag but it adds to much space. And I tried styling the <br> tag but that’s not possible according to this post that I just read. At any rate, I just want the first line to be bold, not both sentences.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:27:52+00:00Added an answer on May 26, 2026 at 1:27 am

    @BoltClock has the CSS answers.

    If you are looking for cross-browser compatibility and you are willing to use js, you can do the following:

    CSS

    .last_bold{
        font-weight:bold;
        color:red;
        padding-top:2em;
        display:inline-block;
    }
    

    var a = $('.last_wfp').text();
    var b = a.split('. ');
    
    $('.last_wfp').html('<span class="last_bold">' + b[0] + '</span>' + '. ' + b[1]);
    

    EDIT

    Per mr.nicksta’s observation:

    potentially more efficient to look for first index of a period and
    then create a substring from the start to that position? and this
    approach assumes only two sentences per paragraph element, any further
    sentences are lost.

    Here is the revised code, that should handle any # of sentences.

    var a = $('.last_wfp').text();
    var b = a.slice(0, a.indexOf('. '));
    var c = a.slice(a.indexOf('. '), a.length);
    
    $('.last_wfp').html('<span class="last_bold">' + b + '</span>' + c);
    

    Revised example: http://jsfiddle.net/jasongennaro/3ZKP9/5/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one has me kind of stumped. I want to make the first word
First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS
I want to make a php search query. First put a sentence and explode
I want to make a php search query. First, I put a sentence and
I'm trying to make my first web service client for the eBay API using
Assuming the file exists (using os.path.exists(filename) to first make sure that it does), how
I'm starting to make my first C program in awhile using GTK+. I've learned
I'm just about to make my first trip into the world of JNI (Java
First, to make my job explaining a bit easier, here's some of my code:
I just wrote my first web service so lets make the assumption that my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.