Mugan Posted March 3, 2020 Share Posted March 3, 2020 I have a function which echos an array output, which creates links on a page related to that page. It all works well, but the CSS is making the links blue and purple as standard, and I want to overwrite this to make the links white. What can I add to the code to overwrite the style of the echo? The font size is working, but the colour is being overridden. The code I currently have is: echo "<p> <font color='ffffff' size='4pt'>$echo</font></p>"; What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/310184-override-css-on-an-echo/ Share on other sites More sharing options...
Barand Posted March 3, 2020 Share Posted March 3, 2020 (edited) Don't use deprecated html markup, such as font color. Use style attribute. echo "<p style='font-size:4pt; color:#ffffff'>$echo</p>"; or define a class for those links in your css .mylink { font-size: 4pt; color: #FFFFFF; } then echo "<p class='mylink'>$echo</p> NOTE: I have no way of knowing what $echo contains. If it contains <a> tag then the styling will need to be applied there and not to the <p> Edited March 3, 2020 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/310184-override-css-on-an-echo/#findComment-1575083 Share on other sites More sharing options...
Mugan Posted March 4, 2020 Author Share Posted March 4, 2020 Thanks Barand, setting up the class worked perfectly! Quote Link to comment https://forums.phpfreaks.com/topic/310184-override-css-on-an-echo/#findComment-1575117 Share on other sites More sharing options...
cyberRobot Posted March 4, 2020 Share Posted March 4, 2020 Are these links appearing in a particular section (e.g. page footer) of the website? If so, the styles could also be applied to all links in that section. That way you don't need to create extra classes. For example, if your links are in an HTML5 footer tag: <footer> <p class="mylink"><?=$echo?></p> </footer> You could style the links with the following: footer a { font-size: 4pt; color: #FFFFFF; } 1 Quote Link to comment https://forums.phpfreaks.com/topic/310184-override-css-on-an-echo/#findComment-1575126 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.