Can a stylesheet style every element here without classes?

I’m developing a CMS plugin that generates HTML. I want to let users style the HTML any way they want. Here is the HTML:

<div id="ss:">
<table>
    <colgroup>
    <col span="1">
    <!-- span can ranges from 3 to 6. -->
    <col span="4">
    <col span="4">
    </colgroup>
    <thead>
    <tr>
        <th rowspan="2">Variable text goes here</th>
        <!-- span can ranges from 3 to 6. -->
        <th colspan="4">Responses</th>
        <th colspan="4">Percentage</th>
    </tr>
    <tr>
        <!-- this row could contain from 6 to 12 headings -->
        <th>Small</th>
        <th>Med.</th>
        <th>Large</th>
        <th>Tot.</th>
        <th>Small</th>
        <th>Med.</th>
        <th>Large</th>
        <th>Tot.</th>
    </tr>
    </thead>
    <tbody>
    <!-- one more more rows with this structure -->
    <tr>
        <th>1. What size Coke do you prefer?</th>
        <td>24</td>
        <!-- largest number surrounded by strong tags -->
        <td><strong>28</strong></td>
        <td>0</td>
        <td>52</td>
        <td>46</td>
        <!-- largest percent surrounded by strong tags -->
        <td><strong>54</strong></td>
        <td>0</td>
        <td>100</td>
    </tr>
    </tbody>
</table>
</div>

I’ve placed the HTML inside div with an ID to allow users to select only elements within it. So my questions are:

Can a stylesheet style every element here without using classes, even if that means using pseudo-classes like nth-child?

Would that be a good practice? If not, what is a good strategy?

I could actually generate a class for every element, but where’s the line between that’s good and that’s crazy?

You should have no problem detecting each element within that HTML.

As far as individually styling cells / headers, it’s unlikely the user will want to differentiate header styles each.

You could use nth-child if need be but you probably won’t have to.

Could you give us an example of what you don’t know you could style / select and we will show you? Right now the only answer we can give you is “its possible, but without a specific example we cannot help further.”

Thanks. It won’t be me doing the styling, so as long as it’s possible, it’s all good.

As for individually styling cells and headers, perhaps someone would want rows with alternating background color, say two rows white alternating with two rows light gray. Others might want to make vertical divisions, styling the columns for numbers one way, and styling the columns for percentages another way.

But if I don’t need to add classes, so much the better. Of course, there is the tiny performance difference between classes, which are specific, and combining descendants, but that’s not an issue.

Thanks again.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.