Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some hidden divs that I show via JavaScript when a button is clicked. Right now, I'm hiding them with by using inline styling (i.e. style="display:none;").

This works, but are there general rules or guidelines to follow to determine if I should use inline styles or styling via stylesheets and class selectors?

share|improve this question

migrated from Dec 19 '11 at 6:09

This question came from our site for professional and enthusiast programmers.

Possible duplicate of For web apps (vs web pages) why not put scripts and css inline? – gnat May 27 at 15:33
up vote 7 down vote accepted

Best Practice is to avoid using in-line styles where possible so Yes I would suggest you use the class="hidden"

Check out this link for more information on best practices with inline styles vs external:

share|improve this answer
where ( 1 ) { use_CSS_classes() ; } – Dave Jacoby Dec 20 '11 at 3:28

Sure, why not? For example:

   <style type="text/css">
   font-family:"Times New Roman";


  <div class="hidden">This CSS example is hidden!</div>
  <p>This paragraph is visble.</p>


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.