Use another s-control as a CSS file
If you build a number of s-controls that provide custom web UIs to the users, you are probably using styles for formatting the page. This is usually done within a < style >
tag inside the s-control. If you have a number of s-controls that produce a similar look and feel, then you are probably copying the styles to each s-control. To change the design, you end up making changes in each s-control.
I was doing some s-control development recently and I got to thinking whether I could maintain my styles in a separate s-control and then reference that s-control like I would a CSS file. It worked! This is synonymous with maintaining a separate CSS file on your web server rather than embedding the styles within a < style >
tag. This will allow you to change the styles of all of your s-controls from a single location.
An example of referencing an s-control as a CSS file is below. To reference an s-control containing your styles, simply use the the following code.
< link href="/servlet/servlet.Integration?lid={ID_OF_YOUR_CSS_S-CONTROL}” type=”text/css” rel=”stylesheet” >
Depending upon the amount of s-control development you do, this may or may not be necesary. But it’s a cool trick to know if you need it.
If you are developing something to upload to AppExchange for others to use, be careful going this route because the ID of the s-control you reference will be different in each Org your package gets downloaded to.