Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 stackoverflow.com Dec 19 '11 at 6:09

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

2 Answers 2

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: http://webdesign.about.com/od/css/a/aa073106.htm

share|improve this answer
where ( 1 ) { use_CSS_classes() ; } –  VarLogRant 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.