Page 1 of 1

SOLVED: php form & styling problem

Posted: Tue Feb 07, 2012 9:34 pm
by mondsteigen
I have a .php that looks something like

Code: Select all

<html>
<link href="template.css" rel="stylesheet" style="text/css">
<body>
--- some stuff ---
<?php
echo '<form action="template.php" method="post">';
echo '<span class="hello"><input type="radio"  checked="checked"value="a"/>Hello</span><br/>';
--- some more <input type="radio">---
echo '<input type="submit">';
echo '<p class="warning">Be caeful!</p>';
echo '</form>';
?>
</body>
</html>
My .css looks like

Code: Select all

span.wrong{background-color: pink}
p.warning{color: red}
Q1: The first one (span.wrong) works, but the second one (p.warning) doesn't work. I don't get any error messages, and it gives the built-in margin for the p tag,but the text color doesn't turn red. Why? Is this fixable?

Q2: I wanted to divide the php section into two by using echo '<div id="sbox">'; which did not work. Is there any way that I can use div in php for the styling purpose?

Re: php form & styling problem

Posted: Tue Feb 07, 2012 10:54 pm
by social_experiment
mondsteigen wrote:The first one (span.wrong) works, but the second one (p.warning) doesn't work. I don't get any error messages, and it gives the built-in margin for the p tag,but the text color doesn't turn red. Why? Is this fixable?
Probably inheriting it's color attribute from somewhere else in the style sheet; are those two declarations the only values in your stylesheet?
mondsteigen wrote:Q2: I wanted to divide the php section into two by using echo '<div id="sbox">'; which did not work. Is there any way that I can use div in php for the styling purpose?
What results did you get when trying? I don't understand the second part of the question; styling is done by css only. You can add the div using php (echo '<div>') but you would still have to style it in a css file

Re: php form & styling problem

Posted: Wed Feb 08, 2012 5:31 am
by Celauran
social_experiment wrote:
mondsteigen wrote:The first one (span.wrong) works, but the second one (p.warning) doesn't work. I don't get any error messages, and it gives the built-in margin for the p tag,but the text color doesn't turn red. Why? Is this fixable?
Probably inheriting it's color attribute from somewhere else in the style sheet
Indeed. Use something like Firebug to check which rules are being applied. There's probably something in there with higher specificity.

Re: php form & styling problem

Posted: Wed Feb 08, 2012 5:23 pm
by mondsteigen
social_experiment wrote:What results did you get when trying? I don't understand the second part of the question; styling is done by css only. You can add the div using php (echo '<div>') but you would still have to style it in a css file
Sorry for not explaining clearly. In my .css I have

Code: Select all

#sbox{border: 3px solid yellow;}
It doesn't give me any error message, but the border does not show up.

Re: php form & styling problem

Posted: Wed Feb 08, 2012 5:27 pm
by mondsteigen
Celauran wrote:Indeed. Use something like Firebug to check which rules are being applied. There's probably something in there with higher specificity.
Thanks for the suggestion. I checked with Firebug just quickly and didn't spot anything. I'll check it more carefully.

Re: php form & styling problem - SOLVED

Posted: Wed Feb 08, 2012 6:05 pm
by mondsteigen
I don't know why, but everything is working now. I didn't touch either .php or .css, but just ran the page again. Honestly, it wasn't working yesterday.

Re: SOLVED: php form & styling problem

Posted: Wed Feb 08, 2012 7:23 pm
by Celauran
Could be that your browser had an older version of the style sheet cached. So long as it's working now.

Re: SOLVED: php form & styling problem

Posted: Thu Feb 09, 2012 4:29 pm
by mondsteigen
Celauran wrote:Could be that your browser had an older version of the style sheet cached. So long as it's working now.
That's a scary thought. I messed up my machine recently. I don't know the exact damage. So far, it's running without any major problem. Anyway, I want to resurrect the problem from a week or so ago and want to ask you a question.