How to Apply CSS Style Override to Text Within a Post (3 posts)

  1. mbzo2006
    Posted 4 years ago #

    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?

  2. Michael
    Part-Time Forum Moderator
    Posted 4 years ago #

    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;
    <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;
    #post-123 ul { list-style-type: square!important; }

  3. mbzo2006
    Posted 4 years ago #

    That sounds great. Thanks very much for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic