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 4037998
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:25:06+00:00 2026-05-20T12:25:06+00:00

In WordPress, the title of a blog post will usually be formatted using an

  • 0

In WordPress, the title of a blog post will usually be formatted using an ID element composed of a prefix such as ‘post’, that never varies, followed by variable numerical suffix generated by WordPress, corresponding to the sequential post number that is unique for each post.

In the WordPress theme single.php file, using html 5 (but the issue is the same with HTML 4), the code for the blog post title would look as follows:

<article id="post-<?php the_ID(); ?>" role="main">

This generates the following html, say:

<article id="post-5434">

I’m having difficulties applying a style to the ID, because unless I’m mistaken there doesn’t seem to be a way of applying a style to an element when part of its name varies. In this instance, what I need to do is to style the ID as follows:

#post-[sequential number] {
    position: relative;
}

#post-[sequential number] blockquote,#post-[sequential number] ul,#post-[sequential number] ol {
    color: #555;
    margin: 0 14px 5px;
    line-height: 1.5;
}

#post-[sequential number] ul li,.entry ul li {
    list-style-type: disc;
    margin: 0 20px 5px;
}

#post-[sequential number] ol li {
    list-style: decimal;
    margin: 0 20px 5px;
}

#post-[sequential number] blockquote {
    font-style: italic;
    border-left: 1px solid #ccc;
    margin-left: 21px;
    padding-left: 10px;
}

in order to apply the styles listed above to descendants of the #post-[sequential number] ID.

In this instance, adding a class (say, <article id="post-[sequential number]" class="blog-post"> to the ID wouldn’t work, since position:relative has to be applied to a block element.

Of course, this result could be easily achieved by adding an extra block element (say, <div class="blog-post">) in between #post-[sequential number] and its descendants, and applying the desired styles to it. But the whole point of using html 5 is to remove unnecessary div elements to make for more semantic markup, so I’d like to find a solution that works without this.

I’ve saved a working copy of the plain index.html and style.css files (without the WordPress markup) in my sandbox that reflect the above description (i.e., with the ID ‘#post-5434’ in the html and #post (with ‘position:absolute’) in the css): they can be accessed here. As you can see, obviously, the desired styles aren’t applied to the descendant blockquote and ul elements.

UPDATE
There are three possible solutions, all equally valid and appropriate in certain circumstances. See below.

  • 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-20T12:25:07+00:00Added an answer on May 20, 2026 at 12:25 pm

    @Sotiris’ answer is the way to go in CSS. However, if you can edit your WordPress theme, you could add class="post" to the HTML, e.g

    <article class="post" id="post-<?php the_ID(); ?>" role="main">
    

    To produce this HTML:

    <article class="post" id="post-5434">
    

    Then use the class in your CSS:

    .post {
        position: relative;
    }
    
    /* and so on... */
    

    This CSS has the advantage of working in IE 6.

    Edit:

    In this instance, adding a class (say, <article id="post-[sequential number]" class="blog-post"> to the ID) wouldn’t work, since position:relative has to be applied to a block element.

    <article> is a block-level element. If it’s not showing up as such in your browser, pop this into your CSS file:

    article {
        display: block;
    }
    

    HTML5-aware reset stylesheets like Eric Meyer’s do this.

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

Sidebar

Related Questions

I'm starting a Wordpress Blog that will have adult content on it, so I'll
WordPress requires you give each blog post at least two fields: a title and
I've got a WordPress powered blog that I'm trying to get setup on our
I am using wordpress and use custom permalink structure: /%category%/%postname%/ My problem is that
I'm running a wordpress blog and would like to access the actual file that
I'm using Wordpress for my website. What I'm trying to achieve is that if
I've used a WordPress blog and a Screwturn Wiki (at two separate jobs) to
i have a wordpress blog and want to give people the same user experience
I'm migrating my WordPress blog and phpBB Forum into a new hosting server. I
I recently made this wordpress blog, where you can sign up a team for

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.