Andrew P
Andrew P

Reputation: 1597

PHP: CSS-styling a table printed out by PHP

So basically i have two php files, one with all the functions etc. and one with mixed php and html code.

<table>
   <?php echo read(); ?>            //This prints a full table with <tbody> etc.
</table>

My question: How do I access this PHP printed html code from my CSS style sheet? It s a seperate file and i have linked it correctly etc. (since it styles all the html code on the same file)

I have tried just putting

tbody { width:100px; padding: 20px;}

and all those normal ones, but for som reason it doesn't apply to the code the PHP prints out.

Suggestions? (new to PHP, be nice)

Upvotes: 0

Views: 101

Answers (2)

Andrew P
Andrew P

Reputation: 1597

So if anyone stumbles on this thread with the same problem, I managed to solve it by putting all the CSS info in the <table> tag like this:

<table
        style="
            width:480px;
            margin-left:10px;
            font-family: calibri;
            background-color:white;
            color:black;
            padding:5px;
            border:1px solid black;
        "
        >

Upvotes: 0

Alex
Alex

Reputation: 196

Add a class to the <table> tag like <table class="my-table"> and then try to add in your css file

.my-table{ width:100px; }

You should apply the css styles to the table tag.

Upvotes: 1

Related Questions