WordPress.org

Support

Support » How-To and Troubleshooting » How to Apply CSS Style Override to Text Within a Post

How to Apply CSS Style Override to Text Within a Post

  • Pretty sure this is a no brainer but here goes:
    what is the most efficient (or laziest person´s) way to apply CSS style overrides to elements WITHIN any given post (not all posts).

    For example: a wordpress theme has styles for unordered lists

      but within post “X”, I want to apply a CSS style override to one particular list called “special”. I might want to repeat the same style later.

    Adding inline css within the post editor seems to work but is there an alternative or “smarter” way? <ul style="list-style-none; display:inline; bla bla bla;><li>Some stuff here</li></ul>

    Does a custom stylesheet override the theme´s default style? Will it style classes defined within a post?

Viewing 2 replies - 1 through 2 (of 2 total)
  • many themes are using a css id with the post id inthe post div, which you can use to specifically target any style within a post;
    example:
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    which gives you, for instance:
    #post-123 ul { ... }

    if that is not enough, you can force any individual style by adding !important before the semicolon;
    example:
    #post-123 ul { list-style-type: square!important; }

    That sounds great. Thanks very much for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Apply CSS Style Override to Text Within a Post’ is closed to new replies.
Skip to toolbar