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 trialJoseph Longo
1,074 PointsCSS for Forms
Hello,
I was reviewing the CSS for this course, and I am curious what the following selectors and properties do:
*, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
select { padding: 6px; height: 32px; border-radius: 2px; }
fieldset { margin-bottom: 30px; border: none; }
legend { font-size: 1.4em; margin-bottom: 10px; }
label { display: block; margin-bottom: 8px; }
label.light { font-weight: 300; display: inline; }
4 Answers
Isaac Asante
4,752 PointsHere are the meanings.
1) You are using the universal selector to target all elements. Then you are using the box-sizing property with the value border-box to force the browser to render your elements' boxes with the specified width and height, and place the border and padding inside the boxes. Via the additional use of -moz- and -webkit- prefixes, you are ensuring that Safari and Firefox also understand your declaration.
2) You want your Select form elements to have 6 pixels of padding on all directions (top, right, bottom and left), then you are setting these element's height to 32 pixels and applying a border radius of 2 pixels on all corners to have slightly rounded corners.
3) You want your Fieldsets to have 30 pixels of margin at the bottom and no border.
4) You want your Legends (which are the captions of your fieldsets) to be 1.4 times larger than your default font-size, and you're setting a 10 pixels margin at the bottom.
5) You want your form's labels to appear as block-level elements and have 8 pixels of margin at the bottom.
6) You want your label element(s) with the class "light" to be slightly emboldened, and appear as inline elements.
Happy coding!
Isaac Asante
4,752 PointsNope, in this case, select is an HTML element that shows a menu of options. More here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
For the pseudo-elements ::before and ::after, watch this Treehouse lesson: http://teamtreehouse.com/library/css-foundations/advanced-selectors/pseudoelements-before-and-after
To understand the possible values of the box-sizing property, read this Treehouse blog: http://blog.teamtreehouse.com/box-sizing-secret-simple-css-layouts
Since you are new to CSS, I recommend you go through all the necessary CSS courses. Most importantly, the following:
- CSS Basics: http://teamtreehouse.com/library/css-basics
Hope I helped there...
Joseph Longo
1,074 PointsThank you!! I appreciate all of your help.
Isaac Asante
4,752 PointsYou're welcome! Helping others like you makes me a better web designer, after all :)
Joseph Longo
1,074 PointsMy previous comment was a bad one. I should have worded it better. When I stated the * is similar to the SQL statement SELECT * FROM... I was referring to the asterisk, not the word SELECT. Have you done any PHP/MySQL coding before? The SELECT * FROM (database_name) WHERE ="" statement would select everything from a database, since the asterisk was used. I guess the asterisk is similar for HTML in that it selects all of the elements??
Isaac Asante
4,752 PointsHey Joseph, I've never done PHP/MySQL before, but in CSS, the styles applied to the universal selector (*) affect all the elements on the HTML document the stylesheet is linked to.
Here are further details on the universal selector: https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors
You can also read this old thread on the universal selector's specificity: https://teamtreehouse.com/forum/clarification-on-how-a-universal-selector-works
Joseph Longo
1,074 PointsJoseph Longo
1,074 PointsFirst, thank you for your answers!
So, the * selects all the elements? I guess that makes sense, kind of like the SQL SELECT * FROM...??
What does the *:before and *:after selectors do? When would it be good or necessary to use *, *:before, and *:after? When would it be good or necessary to use the box-sizing? I noticed the possible values for box-sizing are:
1) content-box 2) border-box 3) initial 4) inherit.
What are the differences between each one.
Although I've built a few php sites using fairly simple CSS, I am new to CSS and proper web design. I'm sure a webmaster would have a coronary over some of the php code I've written, stating it's the furthest thing from being valid php, but my site works...