html style tag doesn't work on php code? (5 posts)

  1. platplaas
    Posted 3 years ago #

    I can't get the following to work:

    <span id="featured-excerpt"><?php the_excerpt(); ?></span>

    The CSS style will work for anything before or after the php for excerpt, but the excerpt itself refuses to be styled. The only way I seem to have any success is using this approach, where I try to place the php inside the span tag. But it creates a new single-space blank line after the php ouput....

    <span id="featured-excerpt" <?php the_excerpt(); ?></span>

    Any pointers would be appreciated.

  2. WPyogi
    Forum Moderator
    Posted 3 years ago #

    Please post a link to a page where this situation exists.

  3. platplaas
    Posted 3 years ago #

    I would post a link, but it is a non-public development version on my local machine. I am using a child theme of the oxygen theme with custom css in the child theme's CSS file.

    Per my note above, the problem is that the php is resisting being styled. When I wrap the above-mentioned php script with span tags, and add some borders, then what happens is I'll get one line with a blank space in a border box, then a line with the php excerpt output (but with no styling applied) and then another line with another blank space inside the CSS border box.

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

    try working with a browser inspection tool such as Firebug to investigate which styles are overwriting your span css class.

    the_excerpt() automatically wraps the result in a html paragraph tag which might get styled in your theme.

  5. platplaas
    Posted 3 years ago #

    @alchymyth - yes - this is what the issue was. I solved the issue with exactly the approach that you have suggested. When inspecting the element I saw that excerpt() wraps the output in paragraph tags per your comment. i.e. my styles were being overridden. Problem is now solved. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic