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 trialMichael Greig
Front End Web Development Techdegree Student 10,328 PointsEditing CSS directly vs using jQuery
Hi there - when I did this I actually edited the CSS and HTML directly in the jQuery using the .css() and .html() methods. Is it better practice to edit things directly in the CSS and HTML files wherever possible?
2 Answers
Stephan Olsen
6,650 PointsSorry Michael, I did mean that you should NOT be using JavaScript/jQuery for static styling. I've edited my answer now. With that I mean that you should not use JavaScript/jQuery to define the styling of your website. You should using it for interactivity. For example if a user clicks a button, you could use jQuery to change the styling of some element. But you should not be using jQuery to setting the initial styling of this element.
I did not watch his video, but basically, any styling that you can put in a stylesheet, should be put in the stylesheet.
Stephan Olsen
6,650 PointsYou should not be creating your stylesheet with jQuery so to say. Your styling should be kept in a seperate stylesheet. This makes it easy to track which elements have which styles, and it makes it easy to change the styling. You can use JavaScript and jQuery to change the styling depending on some action the user performs. But you should not be making static styling with JavaScript/jQuery.
Michael Greig
Front End Web Development Techdegree Student 10,328 PointsThanks for such a speedy and helpful response Stephan! Can I just double check - in your last sentence, did you mean to say 'But you should NOT be making static styling with JavaScript/jQuery'? Have I understood that right?
Also, what makes styling 'static'? Is the styling behind the 'We build great apps' and 'email us' bars in this video static?
Thanks again!
Michael Greig
Front End Web Development Techdegree Student 10,328 PointsMichael Greig
Front End Web Development Techdegree Student 10,328 PointsMakes perfect sense - thanks very much Stephan!