CSS and PHP

liunx

Guest
If I attach a CSS to a page will it apply to html within php script? I have a page with 4 scripts in it and am having problems getting CSS to format all text ie all labels for <input...> within the scripts, do I need to specify within each <form> or what?<br />
Any help appreciated.<br />
<br />
BobNZ<!--content-->the stylesheets are applied at the client browser.<br />
<br />
the PHP script is enacted at the server.<br />
<br />
<br />
This means that the answer is YES, any stylesheets will be followed by any HTML, whether it is generated by PHP or not.<br />
<br />
The problems you are having are in the final HTML as the brower sees it.<br />
<br />
Could you give us an example of your stylesheet and the section of HTML code you are seeing the problems in?<!--content-->Thanks for the quick reply.<br />
<br />
Ok here goes, bear in mind that this is just a beginers approach.<br />
<br />
font<br />
{<br />
font: small-caps normal small/normal verdana, Arial, sans-serif;<br />
color:black;<br />
text-transform: none;<br />
text-decoration: none;<br />
<br />
}<br />
and that didn't work so I tried this...<br />
font<br />
{<br />
font: small-caps normal small/normal verdana, Arial, sans-serif;<br />
color:black;<br />
text-transform: none;<br />
text-decoration: none;<br />
<br />
}<br />
tbody {<br />
font-family: Verdana, Arial, Helvetica, sans-serif;<br />
font-size: small;<br />
font-style: normal;<br />
line-height: normal;<br />
font-weight: bold;<br />
font-variant: normal;<br />
text-transform: none;<br />
color: #000000;<br />
text-decoration: none;<br />
}<br />
and this is the some of the script I'm trying to apply it to<br />
<br />
print "<table width=\"80%\" bordercolor=\"#FFFFFF\" bgcolor=\"#3399CC\" >";<br />
print " <tr> <br />
<td width=\"7%\">WSID:</td><br />
<td width=\"11%\"><input type=\"text\" name=\"WSID\" value=\"$row[0]\" size=\"13\"></td><br />
<td width=\"9%\">Data Entered By:&nbsp;</td><br />
<td width=\"11%\"><input type=\"text\" name=\"DataEnteredBy\" value=\"$row[20]\" size=\"13\" > </td><br />
<td width=\"10%\">&nbsp;&nbsp;OS:</td><br />
<td width=\"10%\"><input type=\"text\" name=\"OS\" value= \"$row[13]\" size=\"13\"> </td><br />
<td colspan=\"2\"><h2 align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<u>Location</u> </h2></td><br />
</tr><br />
<tr> <br />
<td height=\"26\">Make:&nbsp;</td><br />
<td><input type=\"text\" name=\"Make\" value=\"$row[1]\"size=\"13\"> </td><br />
<td>Date Entered:</td><br />
<td><input type=\"text\" name=\"DatEnt\" value=\"$row[19]\"size=\"13\"></td><br />
<td>Memory:</td><br />
<td><input type=\"text\" name=\"Memory\" value=\"$row[8]\"size=\"13\"> </td><br />
<td width=\"9%\">Department</td><br />
<td width=\"33%\"><input type=\"text\" name=\"Dept\" value=\"$row[22]\" size=\"13\"> </td><br />
</tr><br />
<tr><!--content-->just a tip, i prefer to write my code this way:<br />
<br />
<br />
// some PHP code<br />
?><br />
<br />
<table width='80%' bordercolor='#FFFFFF' bgcolor='#3399CC'><br />
<tr><br />
<td width='7%'>WSID:</td><br />
<td width='11%'><input type='text' name='WSID' value='<?php echo $row[0]; ?>' size='13'></td><br />
<br />
...etc...<br />
<br />
</tr><br />
</table><br />
<br />
<?php<br />
// more php code<br />
<br />
<br />
when you declare a style, you are saying which tag it applies to:<br />
<br />
font<br />
{<br />
color : #33CC33;<br />
}<br />
<br />
This applies to <font> tags.<br />
<br />
<br />
As your labels are in <td> tags, I would do this:<br />
<br />
1. change your <td> tag to include a class...<br />
<td class='label'><br />
<br />
2. put in a style definition for 'label' classed <td>'s:<br />
td.label<br />
{<br />
font-family : Verdana, Arial, Helvetica, sans-serif;<br />
font-size: small;<br />
font-style: normal;<br />
line-height: normal;<br />
font-weight: bold;<br />
font-variant: normal;<br />
text-transform: none;<br />
color: #000000;<br />
text-decoration: none;<br />
}<br />
<br />
<br />
More info about sylesheets, and some good tutorials can be found at <br />
<!-- w --><a class="postlink" href="http://www.w3schools.com">www.w3schools.com</a><!-- w --><!--content-->Hey thanks, thats just what I wanted. Awesome.<br />
<br />
BobNZ<!--content-->Run yur CSS through the checker at: <!-- m --><a class="postlink" href="http://jigsaw.w3.org/css-validator/validator-uri.html">http://jigsaw.w3.org/css-validator/validator-uri.html</a><!-- m --> to make sure you catch any typos etc.<!--content-->Originally posted by BobNZ <br />
If I attach a CSS to a page will it apply to html within php script? I have a page with 4 scripts in it and am having problems getting CSS to format all text ie all labels for <input...> within the scripts, do I need to specify within each <form> or what?<br />
Any help appreciated.<br />
<br />
BobNZ <br />
<br />
This is the kind of thing you could have just tried and see what happened. The browser knows not and cares not where the HTML code comes from, a script or direct from a text file on the server, it all gets slurped into the browser and treated the same. As long as your html page is correctly linked to the style sheet it will work just fine.<!--content-->
 
Back
Top