• Hello!

    Please, I need help styling a
    tag inside a PHP code. (I am new to PHP, I do not write PHP code).
    I tried writing the styling inside the tag, but it didn’t work.
    This is the code:

    <form name="post" action="<?php echo get_permalink(); ?>" method="post" id="post" style="text-align: left;">
    
    <ol>
    <?php
    for ($i = 0; $i < $num_questions; $i++) {
        echo "<p><li>" . wqp_escape_string($question[$i]) . "</li>\n";
        $order_answers = array_keys($answer[$i]);
        shuffle($order_answers);
        while (!is_null($j = array_pop($order_answers))) {
            echo "    <input type=\"radio\" name=\"answer[{$i}]\" id=\"answer-{$i}-{$j}\" value=\"{$j}\" /> <label for=\"answer-{$i}-{$j}\">" . wqp_escape_string($answer[$i][$j]) . "</label><br />\n";
        }
        echo "</p>\n";
    }
    ?>
    </ol>
    
    <p class="submit">
    <input type="submit" name="submit" style="font-weight: bold;" value="Enviar respuestas" />
    </p>
    
    <input type="hidden" name="quiz_id" id="quiz_id" value="<?php echo wqp_safe_value($quiz_id); ?>" />
    
    </form>


    [Sorry, your list tags totally messed up the parser here – some was deleted]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Why are you trying to use inline styles? Use the tags, ids or classes to use external CSS. What is the rendered HTML code and what are you trying to do to it?

    Please carefully use the code buttons when posting code here, or better yet, use a pastebin.

    Thread Starter alemist

    (@alemist)

    Hi WPyogi!
    Thank you very much for answering!

    I am trying to style the <li> tag whithin the line:

    echo "<p><li>" . wqp_escape_string($question[$i]) . "</li>\n";

    from the code above.

    I want to use this style: style="font-weight: bold;"

    I can use external classes or ids but I don’t know how to insert them withih the <li> tag in the code. (I tried with an inline style using style="font-weight: bold;" and it didn’t work).

    I am rendering this HTML line:
    <li>¿Con cuál frase te identificas más?</li>

    Just in case, I pasted in pastedbin the complete HTML generated.
    This is the link: http://pastebin.com/pnUdsJsP

    How could I do the rendering??

    Thank you very much for your help in advance.

    Thread Starter alemist

    (@alemist)

    I am using the Code bottom for code lines, but it seems it didn´t work.
    Please, let me know if you can see the message properly.
    I will paste it again if that is the case.

    Try adding a class to the form tag or the <ol> tag – then you can use that in your external CSS.

    general, when using quotation marks in your code, make sure to either use single quotes and double quotes in the correct places, or escape the quotes;

    example – escaped quotes:

    echo "<p><li style=\"font-weight: bold;\">" . wqp_escape_string($question[$i]) . "</li>\n";

    example – different quotes, i.e. single quotes for the strings, double quotes for the style:

    echo '<p><li style="font-weight: bold;">' . wqp_escape_string($question[$i]) . '</li>'."\n";

    or possibly, double quotes for the strings, single quotes for the style:

    echo "<p><li style='font-weight: bold;'>" . wqp_escape_string($question[$i]) . "</li>\n";

    Thread Starter alemist

    (@alemist)

    Thank you WPyogi and Alchymyth.

    I just found the ID for that area and applied the style in the external CSS.

    #post-852 li{
    	font-weight: bold;
    }

    And it worked.
    But I don’t know if this post ID is permanent.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Inline style for PHP code from a Pluggin’ is closed to new replies.