This is my table:
<table width="100%">
<tr ><td width="35%" height="30" class="left-info" >Criminal Id :</td>
<td width="65%" class="right-info" >CR7887898652</td></tr>
<tr><td height="30" class="right-info" >Full Name :</td><td class="left-info" ></td></tr>
<tr><td height="30" class="right-info" >Date of Birth :</td><td class="left-info" ></td></tr>
</table>
How can I remove these repeating use of class for each table data. As, I’ve used class="left-info" for left side table data and class="right-info" for right side table data. But, this make the mesh of coding, can anyone suggest me how can I do the same style with minimal code?
You can either switch to a non-table layout (perhaps a
DLmay suit your needs better), or if you must use a table, consider using thecolelement, which you can apply aclassattribute to.Example
Using your example above, this is how I would suggest using the
colelement.But, taking into account your example, I think you could accomplish your goal with better semantics and less code if you make use of
THelements and pure CSS:…
At this level, it shouldn’t really matter if you use a
DLor aTABLEas they both are semantically rich elements when used like this. IMHO, I still prefer aDL, but truthfully they can be more difficult to style.