The advantages are much the same as separating them from the HTML.<br>By setting classes rather than styles you can then keep all style information within the stylesheet.<br><br>Using the div toggle as an example, say you have multiple methods all of which control the visibility of different divs throughout a site. Each one is setting an elements 
style.display = &quot;none&quot; or similar<br><br>Then someone has the bright idea that instead of any of the elements being hidden they should all have their background changed to bright pink with purple dots (or whatever, have their alpha set to 50% etc etc) instead
<br><br>If you are applying the styles directly to the element within your different methods you have to dig through your js file changing each one<br><br>If your toggling a class on/off you simply go to your style sheet and change
<br><br>.toggled {<br>&nbsp;display: none;<br>}<br><br>to<br><br>toggled {<br>&nbsp;background: url(pinkdots.gif);<br>}<br><br>and your done :)<br><br><br><br><div><span class="gmail_quote">On 11/30/06, <b class="gmail_sendername">
Stephan Wehner</b> &lt;<a href="mailto:stephanwehner@gmail.com">stephanwehner@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Could you elaborate? What is the advantage of dynamically setting<br>classes over styles?<br><br>I can see within the HTML document itself, it's good to separate the<br>style. But in the dynamic case I don't see it.<br><br>
Stephan<br><br>On 11/29/06, Aaron Bassett &lt;<a href="mailto:aaronbassett@gmail.com">aaronbassett@gmail.com</a>&gt; wrote:<br>&gt; Why is everyone (well minus a few) so dedicated to adding styles 'inline'??<br>&gt; As we all know styles should be kept in the style sheet etc etc
<br>&gt;<br>&gt; so define a class<br>&gt;<br>&gt; .hide {<br>&gt;&nbsp;&nbsp;display: none; /* or visibility: hidden */<br>&gt; }<br>&gt;<br>&gt; and then add and remove the class<br>&gt;<br>&gt; there are several nice functions out there to do this already or if you use
<br>&gt; the prototype.js library (or even if you dont these methods are easy enough<br>&gt; to remove and add to your own class or create as functions)<br>&gt;<br>&gt; Element.addClassName(el, &quot;hide&quot;);<br>&gt; 
Element.removeClassName(el, &quot;hide&quot;);<br>&gt;<br>&gt; no need to worry if the default property value is inline of block as when<br>&gt; you remove the class it will go back to what it was before, and has the<br>&gt; added benefit of keeping your style away from your function :)
<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; On 11/29/06, Peter Brunone &lt;<a href="mailto:peter@brunone.com">peter@brunone.com</a>&gt; wrote:<br>&gt; &gt;<br>&gt; &gt; Hi Roland,<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;Instead of using 
style.visibility = &quot;hidden&quot;, use style.display=&quot;none&quot;.<br>&gt;&nbsp;&nbsp;Then, to change it back, you set the display to &quot;inline&quot; (it might be<br>&gt; &quot;block&quot;, but I'm pretty sure the default is &quot;inline&quot; for select elements;
<br>&gt; you can look it up if necessary).<br>&gt; &gt;<br>&gt; &gt; Cheers,<br>&gt; &gt;<br>&gt; &gt; Peter Brunone<br>&gt; &gt; ______________<br>&gt; &gt; EasyListBox.com<br>&gt; &gt;<br>&gt; &gt; From: &quot;Dong, Roland&quot; 
<a href="mailto:Roland_Dong@parade.com">Roland_Dong@parade.com</a><br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Hello,<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; I need to dynamically hide and unhide a selection box based on the value
<br>&gt; selected in the first selection box.&nbsp;&nbsp;So if a user selects &quot;a&quot;&nbsp;&nbsp;in selection<br>&gt; box, element id2 should be visible else it should remain hidden.&nbsp;&nbsp;I can use<br>&gt;&nbsp;&nbsp;document.getElementByI(&quot;id2&quot;).style.visibility=&quot;visible&quot;
<br>&gt; to make it visible and<br>&gt; document.getElementById(&quot;ed1&quot;).style.visibility=&quot;hidden&quot;;<br>&gt; to make it disappear.&nbsp;&nbsp;&nbsp;&nbsp;The problem when element id2 disappears, it still<br>&gt; keeps space there and it makes the form look bad.&nbsp;&nbsp; Is there a way to
<br>&gt; dynamically remove the space it occupies?<br>&gt; &gt;<br>&gt; &gt; .......<br>&gt; &gt; &lt;tr id=&quot;id1&quot;&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;select name=&quot;first&quot; onchange=&quot;check(this)&quot;&gt;
<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option&gt;a&lt;/option&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option&gt;b&lt;/option&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/select&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;<br>&gt; &gt; &lt;/tr&gt;<br>&gt; &gt; &lt;tr id =&quot;id2&quot; style=&quot;visibility:hidden&quot;;&gt;
<br>&gt; &gt;&nbsp;&nbsp;&lt;td&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;select name=&quot;second&quot;&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option&gt;c&lt;/option&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option&gt;d&lt;/option&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/select&gt;
<br>&gt; &gt;&nbsp;&nbsp;&lt;td&gt;<br>&gt; &gt; &lt;/tr&gt;<br>&gt; &gt; ..............<br>&gt; &gt; rest of the form....<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Thanks a lot,<br>&gt; &gt;<br>&gt; &gt; Roland<br>&gt; &gt; _______________________________________________
<br>&gt; &gt; Javascript mailing list<br>&gt; &gt; <a href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</a><br>&gt; &gt; <a href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript
</a><br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; Javascript mailing list<br>&gt; <a href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</a><br>
&gt; <a href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</a><br>&gt;<br>&gt;<br>&gt;<br><br><br>--<br>Stephan Wehner<br>&gt; <a href="http://stephan.sugarmotor.org">
http://stephan.sugarmotor.org</a><br>&gt; <a href="http://stephansmap.org">http://stephansmap.org</a><br>&gt; <a href="http://www.trafficlife.com">http://www.trafficlife.com</a><br>&gt; <a href="http://www.buckmaster.ca">
http://www.buckmaster.ca</a><br>_______________________________________________<br>Javascript mailing list<br><a href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</a><br><a href="https://lists.LaTech.edu/mailman/listinfo/javascript">
https://lists.LaTech.edu/mailman/listinfo/javascript</a><br></blockquote></div><br>