Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Henry Morrow
19,425 PointsExternal stylesheet CSS is not being applied to my html form.
I am working on a form for my website included below
<form method="post" action="contact.php">
<label for="name">Name</label>
<input type="text" id="name" name="name" value="<?php if (isset($name)) { echo $name; } ?>" />
<label for="email">Email</label>
<input type="text" id="email" name="email" value="<?php if (isset($email)) { echo $email; } ?>" />
<label for="name">Suggest Item Details</label>
<textarea name="details" id="details"><?php if (isset($details)) { echo htmlspecialchars($_POST["details"]); } ?></textarea>
<input class="field" type="submit" value="Send" />
</form>
The form includes some PHP to grab variables and display so the form doesn't change if someone doesn't submit correctly. When I try to style the form with my external stylesheet none of the styles apply. All of my other styles work for the rest of the page, and if I include the styles as attributes with style="" inside of the input and label tags then the styles I want apply correctly.
This leads me to believe I am not selecting correctly, though I have tried using the following selectors for example for the first input field (not all at the same time) and none of them work:
form input {}
form input[type=text] {}
input[type=text] {}
input[type='text'] {}
#name{}
I have also tried wrapping the for in a div and calling the inputs with a class and id from that div. Am I making a syntax error or maybe my form html is not ordered properly? Any help would be appreciated.
1 Answer
Gurpeer Duhra
4,205 PointsYour link tag should be in between <head></head> tags. If you have renamed your index.html to index.php for PHP to functions with wamp server or so, please show me you entire html and where your CSS file is located.
Henry Morrow
19,425 PointsHenry Morrow
19,425 PointsThe file is located correctly as I mentioned all of the other styles in the index.php file work with my stylesheet. The only elements that don't work are specifically on the form which is why I think my error is in the syntax with which I am trying to style the individual form elements. Here is my index file if that is helpful.