The <col> tag uses to define column properties for each column within a <colgroup> element.So we can say that the <col> tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.
The declaration order affects the each column respectively(just like if you define col for first/second column it show its affect only for first/second column.).This order can be affected by the use of the "span" attribute. This attribute can be used in this tag to affect more than one column with the same declaration. col tag defines in the colgrp tag in table tag.
The most common attributes available for this tag are purely presentational (align, valign, width, char and charoff).We may also use css properties for same work. The <col> tag has no end tag In HTML,while has properly closed tag in XHTML.

You can understand use of <col> tag by a simple example:-

e.g.

<!DOCTYPE html>
<html>
<body>
<p>This example shows a colgroup that has four columns of different widths:</p>
<table border="1">
<colgroup span="3">
<col width="50" background: red;></col>
<col width="100" background: green;></col>
<col width="150" background: yellow;></col>
<col width="50" background: pink;></col>
</colgroup>
<tr>
<td>col 1</td>
<td>col 2</td>
<td>col 3</td>
<td>col 4</td>
</tr>
</table>
</body>
</html>


Result:-
col 1 col 2 col 3 col 4


The following attributes can be set for the <col> tag:-

<br> Tag Attributes

<br clear="none|left|right|all">

Attribute Value Description
align left Data is aligned to the left.It is default value.
center Data is aligned to center
right Data is aligned to right
justify Data is justified.
char The text is aligned to a specific character
charoff number number of characters the content will be aligned from the character specified by the char attribute.Not supported in HTML5.
span number number of columns a <col> element should span
valign top Data is aligned to the top.
middle Data is vertically centered.
bottom aligned to the bottom.
baseline All the cells in a row with this alignment should have their first text line on a common baseline.
width %
pixels
width of a <col> element


Conclusion:--

So the <col> tag use for specifying column properties for each column within a colgroup. You would normally only use this tag if the values for each column is different. Otherwise, you can specify the properties as part of the colgroup tag.

<col> tag का उपयोग colgrp में प्रत्येक column की अलग-अलग properties परिभाषित करने में किया जाता है आपको इस tag को तब use करना चाहिए जब प्रत्येक कॉलम के लिए आपको भिन्न-भिन्न properties use करनी हो अन्यथा सभी columns को समान properties देने के लिए colgrp tag में properties define करनी चाहिए.

0 comments:

Post a Comment