php font format

doctorbill
doctorbill used Ask the Experts™
on
How do I format this output please:
printf('<td><a href="?page=%1$s">Page %1$s</a></td>&nbsp;&nbsp;', $i);

ie colour the fonts or add images in place of text
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Many ways, you can apply CSS to all table elements, all td elements, all anchor (a) elements.

Or you can assign an ID (likely best) + assign your CSS to an id.

You can also create a CSS class if the styling will apply to many elements.

Commented:
To add color or styling, you'd use CSS styles. For example, to make it show white-on-black:

<a href="...." style="color:#fff; background-color:#000;">

To add images, you'd have to find the image and add it with an <img> tag.
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
To color the links you'll need to apply CSS to the <a> elements. Depending on your full HTML, there are a few ways you can do this.

With the a selector (all links in your page):

    a { color: green; }
    a:hover { color: red; }

With a class selector:

    printf('<td><a class="pagination" href="?page=%1$s">Page %1$s</a></td>&nbsp;&nbsp;', $i);
    .pagination { color: green; }
    .pagination:hover { color: red; }

With an ID on a parent element, such as your table:

    <table id="pagination">
    ...
    #pagination a { color: green; }
    #pagination a:hover { color: red; }

Not entirely sure what you mean by adding images. If you want an image in place of the text, you can just wrap it in your <a> tag:

printf('<td><a href="?page=%1$s"><img src="someImage.jpg" title="Page %1$s"></a></td>', $i);

FYI - THere's no need for the &nbsp elements in your code - they're outside of the <td> so will have no effect.

Author

Commented:
Perfect - thanks all. I was trying to add the style in the <td> element instead of the <a tag

Author

Commented:
Thanks all

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial