• Resolved Diomedes

    (@diomedes)


    I’m trying to make the first line of each post (in my blog) automatically small-caps.

    I tried the code below, but it turns the first line of every paragraph into small-caps instead of just the first line. Is there a way to specify?

    p:first-line {
    font-variant:small-caps;
    }

    What I’m looking for is pretty much like what’s built into the Oulipo theme (except that it works in a post with images also) so I tried stealing the code from there, cleaned it up to the best of my rather poor ability, and came up with this code –

    .entry > p:first-child:first-line?{
     ont-variant:small-caps
    	font-family: Georgia, "Times New Roman", Times, serif;
    }

    – which doesn’t work. Help?

Viewing 15 replies - 1 through 15 (of 20 total)
  • You need to get your CSS as specific as possible in your theme. Try using Firefox with the Firebug add-on for this kind of CSS work.
    https://getfirebug.com/

    In the code you copied above, you are missing the “f” in font — don’t know if that was just a typo here or is in your actual code — if the later, that may be the problem?

    Thread Starter Diomedes

    (@diomedes)

    I will, thanks. But I don’t have access to a computer right now, just my iPad.

    Thread Starter Diomedes

    (@diomedes)

    Whoops, that’s a typo here, WPYogi.

    Thread Starter Diomedes

    (@diomedes)

    Aha. An update —

    p:first-child:first-line {
    	font-variant: small-caps;
    	font-size: 14px;
    }

    — that’s the code I used, and it works but only on the posts without images. That’s what happened in the Oulipo theme too, so is there something I can do?

    Looks like you have the images inside p tags — so that’s likely why that’s not working.

    You could always create a class for the styles and add that class to each paragraph where you want the small caps. Not quite as elegant but would likely work okay.

    Actually in the first post, you just have empty p tags above the image:

    <div class="entry">
    <p></p>

    Thread Starter Diomedes

    (@diomedes)

    I don’t see that… Here’s a screengrab of my post HTML.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Use the Browser Inspector Tool Esmi pointed out. These tools are vital for debugging generic CSS issues.

    Well, it was there earlier — I copied it straight from the rendered HTML in Firebug. But no matter, my above post is still relevant — your first paragraphs have links/images in them — the special small caps styles IS being applied — just does not show up as there is no text there to style that way:
    From the rendered HTML:

    <div class="entry">
    <p><a href="https://smellofpopcorn.com/wp-content/uploads/2012/11/wpid-Photo-Nov-12-2012-18141.jpg" target="_blank"......

    Firebug shows this style applied to the above p

    p:first-child:first-line {
        font-size: 14px;
        font-variant: small-caps;
    }

    Thread Starter Diomedes

    (@diomedes)

    Huh. Apologize for my ignorance, but what can I do then?

    (if Firebug is the only answer than I’ll try that out when I have access to a computer)

    Don’t put the images in paragraph tags — though that may be a default from your theme?
    Or as mentioned earlier,

    You could always create a class for the styles and add that class to each paragraph where you want the small caps. Not quite as elegant but would likely work okay.

    i.e.:
    Put this in your CSS:

    p.smallcaps:first-line {
    	font-variant: small-caps;
    	font-size: 14px;
    }

    And for the paragraphs where you want this to appear, add that class to the p tags:

    <p class="smallcaps">

    Firebug is just an INVALUABLE tool for working with CSS — I don’t know how anyone could do much without it when it comes to CSS. It would be like driving with your eyes 90% closed — LOL!

    Thread Starter Diomedes

    (@diomedes)

    Yeah, on the HTML editor it doesn’t show that there are paragraph tags in or around any images.

    The second option makes the entire paragraph small-caps, instead of just the first line automatically regardless of browser system, etc….

    please see to this code.

    p:first-child:first-line {
    font-size: 14px;
    font-variant: small-caps;
    }

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘First line in small-caps?’ is closed to new replies.