Text color in php

Solved
martine et chantal Posted messages 517 Status Membre -  
 bat -
Hello,

I know how to change the color of text like this:

echo '<font color="red">hello</font>';

But how do I do it for a variable?

echo '<font color="red">hello</font>'.$variable;

Configuration: Windows XP / Internet Explorer 8.0

6 réponses

mpmp93 Posted messages 2931 Registration date   Status Membre Last intervention   1 341
 
Hello,

DO NOT USE FONT ANYMORE !!!!!!

It's over! Bearkk! not pretty....

A general rule: any element that affects the presentation of the page (color, size, etc...) should be managed in a style. Example, an alert text,

before:

<b><font color='red'>ALERT</font></b>

now:

<b style='color: red;'>ALERT</b>

For PHP:

<?php
$color = 'red';
?>

<b style='color: <?php echo $color; ?>;'>ALERT</b>

A+
10
Profile blocked
 
*now

<span class="grasrouge">ALERT</span>

css => .grasrouge{font-weight:bold;color:red;}
1
arthezius Posted messages 3756 Status Membre 475
 
Indeed, just as the <font> tag has become obsolete, the <b> tag has as well.

Varaldi Q, we could also embed the CSS code in the tag:
<span style="font-weight:bold;color:#f00;">ALERT</span>

In mpmp93's case, we could even simply replace the <b> tag with the <strong> tag.
0