On Sat, 03 May 2008 15:01:39 -0400
Michael B Allen wrote:

> Hi,
> 
> I'm exploring the idea of using modules of code to emitting reusable
> HTML UI elements like postal addresses, login forms, linked images
> and in turn more sophisticated elements such as invoices, forum posts,
> etc. Because these elements are supposed to be reusable I do not want
> to force style information on the user and yet I need to maximize the
> ease with which the user can apply their own style to each element.
> 
> For example, let's say one of these classes emits some HTML like the
> following:
> 
>   <table>
>   <tr><td colspan="2"><h3>Account Information</h3></td></tr>
>   <tr><td>Username:</td><td>abaker</td></tr>
>   <tr><td>Email Address:</td><td>[EMAIL PROTECTED]</td></tr>
>   <tr><td>Full Name:</td><td>abaker</td></tr>
>   </table>
> 
> Now let's say I want to change the style of h3 and the field labels
> but within this table only. This is basically impossible through CSS
> alone.
> 

It's quite possible like so:

#tableid h3 {
   color: blue /* Unique styles here */
}

#tableid label {
   color: green /* Unique styles here */
}

<table>
<tr><td colspan="2"><h3>Account Information</h3></td></tr>
<tr><td><label>Username:</label></td><td>abaker</td></tr>
<tr><td><label>Email Address:</label></td>
   <td>[EMAIL PROTECTED]</td>
</tr><tr><td><label>Full Name:</label></td> 
   <td>abaker</td>
</tr></table>

But the same code is much cleaner without the table

<div id="accountinfo">
   <h3>Account Information</h3>
   <label>Username:</label>abaker<br>
   <label>Email Address:</label>[EMAIL PROTECTED]<br>
   <label>Full Name:</label>abaker
</div>

Really i shouldn't be promoting label use here as <label> is for form
labels. We should instead use a definition list as it is appropriate.
The enclosing div is then redundant.

<h3 id="account">Account Information</h3>
<dl id="info">
   <dt>Username:</dt><dd>abaker</dd>
   <dt>Email Address:</dt><dd>[EMAIL PROTECTED]</dd>
   <dt>Full Name:</dt><dd>abaker</dd>
</dl>


> One possibility would be to allow the user to supply a class name that
> will be strategically set on some elements like:
> 
>   <div class="myapp">
>   <table>
>   <tr><td colspan="2"><h3>Account Information</h3></td></tr>
>   <tr><td class="fieldlabel">Username:</td><td>abaker</td></tr>
> 
> Then the user can supply their own CSS like:
> 
>   div.myapp h3 {
>       color: #000080;
>       border-bottom: 2px #808080 solid;
>       margin-bottom: 0px;
>   }
>   div.myapp td.fieldlabel {
>       text-align: right;
>       white-space: nowrap;
>   }
> 
> This seems a little clumsy to me but it's the best I can come up with.
> 

Using the above method you can get more specific with id's, allowing CSS
to be fully implemented, and as garish, as needed.

<h3 id="acc">Account Information</h3>
<dl id="inf">
   <dt id="infuser">Username:</dt>
      <dd id="infouser">abaker</dd>
   <dt id="infemail">Email Address:</dt>
      <dd id="infoemail">[EMAIL PROTECTED]</dd>
   <dt id="infname">Full Name:</dt>
      <dd id="infoname">abaker</dd></dl>
</dl>

Full examples with CSS here:
http://www.comptutor.org/mytest/DefinedStyles.htm

-- 
Michael

All shall be well, and all shall be well, and all manner of things shall
be well

 - Julian of Norwich 1342 - 1416
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to