Title: css inside if statement
Last modified: June 27, 2020

---

# css inside if statement

 *  Resolved [danielm04](https://wordpress.org/support/users/danielm04/)
 * (@danielm04)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/css-inside-if-statement/)
 * hello, i want to execute an if statement but i want that the statemtent executes
   a css code and not a php code, the part of the code i have to execute inside 
   the statement is this:
 *     ```
       <body 
       style="text-align:center">
        <div class="popup11" onclick="myFunction11()"><i class='fas fa-star' style='font-size:48px;color:yellow'></i>
         <span class="popuptext11" id="myPopup11">
         <?php echo $spp->current()?><br></span>
       </div>
       </body>
       </html>
       ```
   
 * so, i tried the following to put it inside the if statement
 *     ```
       <body 
       style="text-align:center">
       <?php 
       $sample = "<div class="popup11" onclick="myFunction11()"><i class='fas fa-star' style='font-size:48px;color:yellow'></i>"
       $sample1 = "<span class="popuptext11" id="myPopup11">"
       $sample3 = "<?php echo $spp->current()?><br></span>"
       if ($spp != null) {
       echo $sample
       echo $sample1
       echo $sample3
       }
       else {
       return
       }
       ?>
       </div>
       </body>
       </html>
       ```
   
 * What would you change here? it would be a huge help
    -  This topic was modified 5 years, 11 months ago by [danielm04](https://wordpress.org/support/users/danielm04/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcss-inside-if-statement%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/css-inside-if-statement/#post-12965586)
 * Your code is PHP, outputting Javascript with some inline CSS.
    Which part is 
   variable, and what is the condition you want to check?
 *  Thread Starter [danielm04](https://wordpress.org/support/users/danielm04/)
 * (@danielm04)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/css-inside-if-statement/#post-12966142)
 * [@joyously](https://wordpress.org/support/users/joyously/) thats just part of
   the code, the code will make many stars generate and each star will popup and
   show something that someone wrote when you click on it, so the $spp variable 
   is what the person wrote, it is on php because those things go to a document 
   so i had to use the function seek, the condition is that the $spp cant be null,
   so the star only appears if the line that star is seeking has something wrote,
   without that condition there will be stars there but the popup will be empty
    -  This reply was modified 5 years, 11 months ago by [danielm04](https://wordpress.org/support/users/danielm04/).
 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/css-inside-if-statement/#post-12966469)
 * It doesn’t look correct to me to have <body> and <html> tags, etc. but just to
   use your example
 *     ```
       <body style="text-align:center">
       <?php
       if ($spp != null) : ?>
        <div class="popup11" onclick="myFunction11()"><i class='fas fa-star' style='font-size:48px;color:yellow'></i>
         <span class="popuptext11" id="myPopup11">
         <?php echo $spp->current(); ?><br></span>
       </div>
       <?php endif; ?>
       </body>
       </html>
       ```
   
 * You can make it a function if you need to do it many times.
 *  Thread Starter [danielm04](https://wordpress.org/support/users/danielm04/)
 * (@danielm04)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/css-inside-if-statement/#post-12966521)
 * Thanks, I’m going to try that, and the html and body is just because of the previous
   code.
 *  Thread Starter [danielm04](https://wordpress.org/support/users/danielm04/)
 * (@danielm04)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/css-inside-if-statement/#post-12966709)
 * it did work, thanks

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘css inside if statement’ is closed to new replies.

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [developing](https://wordpress.org/support/topic-tag/developing/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [danielm04](https://wordpress.org/support/users/danielm04/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/css-inside-if-statement/#post-12966709)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
