Text color in php
Solved
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
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 answers
-
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+-
-
-
-
Hello,
In fact, there is nothing that prohibits adding CSS <style></style> in an HTML page... It's not strongly discouraged, it's just discouraged... Why? Simply because it forces the browser to reinterpret the HTML to take these new rules into account...
Regarding the <b> tag, it is not deprecated. It is simply not semantically significant enough.
Style declarations are made at three levels:
- globally in a CSS common to all pages,
- locally by a style.../style usually placed before the body. But in fact, if we place it directly before an element like table, it doesn't disrupt anything:
http://html5.immo-scope.com/index.php?page=html5/tableauDeDebutant
- at the element level with style='....'
Regarding span, it is a marker just like div, meaning it has no significance. HTML5 brings new elements like <time> or <address> that are more explicit alternatives... See details here of what is new and truly obsolete:
http://www.w3schools.com/html5/html5_reference.asp
It's worth noting that for the past year and a half, I have been creating all my personal and professional websites in HTML5 and I have not had any issues...
See you! -
Oh, I'm not criticizing, I'm just saying that it's strongly discouraged because if we have to keep changing the parameters of each html/php page every time we want to tweak the design, we won't be out of trouble!
Nothing forbids it, indeed, we generally do this when we want to make a quick modification, but if we're at the design stage, we might as well keep everything neat in a separate css file, that way, with a simple click, we can change the entire design of our site!
Span and div are generic tags, they don't really have any other purpose than to group elements (text or otherwise) so that we can easily apply attributes to them, or to allow an action on the whole group (like showing/hiding a div, for example).
It's not a matter of being obsolete or not, but just of comfort and "clean" coding.
PS I'm not saying this for you, as these are well-known things, and given your site, you know them; I'm mainly saying this for those who might come across it and who are starting out in web programming.
-