Search code examples
phpstylesinline-styles

inline styling inside php tags


I am working on a website in which I want to do inline style for the text coming from php tags.

The code for that is:

   <p class="mb-0">hello world, <?php echo strtolower($data['client']->client_details->first_name);?></p>

The above code is producing the following output:

hello world, Mike

The word Mike is coming from the database and I have to make it orange color.

Problem Statement:

I am wondering what changes I should make in this code <?php echo strtolower($data['client']->client_details->first_name);?></p> so that the text coming out from it is orange or any other which I want to select.


Solution

  • You've just put all your output's into a singular style controlled by the <p> tag. You could do this styling in multiple ways: in the PHP echo (using HTML and inline CSS) or using straight HTML and CSS (preferred method).

    The method I will provide here is HTML and inline CSS. This can change by adding a class to your stylesheet with the inline style added.

     <p class="mb-0">hello world, <span style="color: orange;"><?php echo strtolower($data['client']->client_details->first_name);?></span></p>