Trying to add color to a link |
Trying to add color to a link |
KenHorse |
Sep 27 2018, 12:11 PM
Post
#1
|
Group: Members Posts: 3 Joined: 27-September 18 Member No.: 26,719 |
Consider the following snippet of PHP:
CODE print " <td align=\"center\">"; if($row[changed]){print "<B><RED>";} print "<a href=\"editmacrorc.php?id=$row[id]&port=$port&tab=$tab\">"; The tag <RED> is a CSS entry that works fine in other code I use: CODE RED {color:red} As you may see, we read in data from a MySQL database and if the 'changed' field contains a '1', we want to make the displayed character bolded and also RED. And if that character is clicked, take us to the new php file (that all works fine). But only the BOLD is displayed but it is not in RED. Not really sure if this an HTML or PHP issue but help! This post has been edited by KenHorse: Sep 27 2018, 12:17 PM |
Darin McGrew |
Sep 27 2018, 04:11 PM
Post
#2
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
|
Darin McGrew |
Sep 27 2018, 04:12 PM
Post
#3
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
Please see the FAQ entry How can I specify colors?
|
KenHorse |
Sep 27 2018, 04:15 PM
Post
#4
|
Group: Members Posts: 3 Joined: 27-September 18 Member No.: 26,719 |
Not to be argumentative but I clearly posted that my color tag works properly otherwise and included the tag in my css file
This post has been edited by KenHorse: Sep 27 2018, 04:15 PM |
Christian J |
Sep 27 2018, 04:19 PM
Post
#5
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
The tag <RED> is a CSS entry that works fine in other code I use: CODE RED {color:red} There is no RED element/tag in HTML, but since browsers don't know that it can still be (ab)used as a CSS selector. It doesn't work on links though, since they use their own color styling. Compare with this: CODE <style>KenHorse {color: red;}</style> ... <KenHorse>ordinary text that's red <a href="">a link with its default color</a></KenHorse> What I'd do is give the link a CLASS attribute value (depending on the value of $row[changed]), and then use that CLASS value as a selector for the CSS. Something like this: CODE if($row[changed]) { print '<a class="changed" '; } else { print '<a class="unchanged" '; // Or no CLASS attribute at all, if you use default styling. } print 'href="editmacrorc.php ... Then you can style the link's CLASS (together with its visited, unvisited, hovered etc states as shown here: https://www.w3.org/TR/2011/REC-CSS2-2011060...-pseudo-classes ). Nit pick: as a sidenote it's good practice to encode ampersands in URLs: ampersands in the URL). |
Lo-Fi Version | Time is now: 23rd April 2024 - 04:36 PM |