HTML Tag
Có thể bạn quan tâm
The HTML <col> tag is used for specifying column properties for each column within a <colgroup> element.
The <col> tag can be handy if you need to specify styles across one or more columns. Rather than apply the styles at the individual <td> level, you can apply it to the <col> element. Then all <td> (and <th>) elements contained within that <col> will be styled accordingly.
Syntax
The <col> tag is written as <col> (no end tag). You can use the span attribute to specify the number of columns to span.
The tag be used within a <colgroup> tag that doesn't have a span attribute.
Like this:
<table> <colgroup> <col class="col-1"> <col span="2" class="normal"> </colgroup> <tr> <td>Cell</td> <td>Cell</td> <td>Cell</td> </tr> </table>Examples
Basic tag usage
Here we apply a different background color to the columns using the <col> tag in conjunction with the CSS background property.
<style> table, td, th { border: 1px solid black; } </style> <table> <colgroup> <col style="background:#AEF642;"> <col span="3" style="background:#F4FBEA;"> <col style="background:orange;"> </colgroup> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> <th>Header 4</th> <th>Header 5</th> </tr> <tr> <td>Cell</td> <td>Cell</td> <td>Cell</td> <td>Cell</td> <td>Cell</td> </tr> <tr> <td>Cell</td> <td>Cell</td> <td>Cell</td> <td>Cell</td> <td>Cell</td> </tr> </table>Attributes
Attributes can be added to an HTML element to provide more information about how the element should appear or behave.
The <col> element accepts the following attributes.
| Attribute | Description |
|---|---|
| span | Specifies how many columns to span. This attribute's value must be a valid non-negative integer greater than zero. |
Global Attributes
The following attributes are standard across all HTML elements. Therefore, you can use these attributes with the <col> tag , as well as with all other HTML tags.
- accesskey
- autocapitalize
- class
- contenteditable
- data-*
- dir
- draggable
- hidden
- id
- inputmode
- is
- itemid
- itemprop
- itemref
- itemscope
- itemtype
- lang
- part
- slot
- spellcheck
- style
- tabindex
- title
- translate
For a full explanation of these attributes, see HTML 5 global attributes.
Event Handlers
Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain "event" occurs. Each event handler content attribute deals with a different event.
- onabort
- onauxclick
- onblur
- oncancel
- oncanplay
- oncanplaythrough
- onchange
- onclick
- onclose
- oncontextmenu
- oncopy
- oncuechange
- oncut
- ondblclick
- ondrag
- ondragend
- ondragenter
- ondragexit
- ondragleave
- ondragover
- ondragstart
- ondrop
- ondurationchange
- onemptied
- onended
- onerror
- onfocus
- onformdata
- oninput
- oninvalid
- onkeydown
- onkeypress
- onkeyup
- onlanguagechange
- onload
- onloadeddata
- onloadedmetadata
- onloadstart
- onmousedown
- onmouseenter
- onmouseleave
- onmousemove
- onmouseout
- onmouseover
- onmouseup
- onpaste
- onpause
- onplay
- onplaying
- onprogress
- onratechange
- onreset
- onresize
- onscroll
- onsecuritypolicyviolation
- onseeked
- onseeking
- onselect
- onslotchange
- onstalled
- onsubmit
- onsuspend
- ontimeupdate
- ontoggle
- onvolumechange
- onwaiting
- onwheel
Most event handler content attributes can be used on all HTML elements, but some event handlers have specific rules around when they can be used and which elements they are applicable to.
For more detail, see HTML event handler content attributes.
Từ khóa » Html Column Tag
-
HTML Col Tag - W3Schools
-
HTML Tables - W3Schools
-
: The Table Column Element - HTML - MDN Web Docs - Mozilla -
HTML:
Tag - TechOnTheNet -
HTML
Tag - GeeksforGeeks -
HTML -
Tag - Tutorialspoint -
HTML Tag » -
HTML Col Tag - Tutorial Republic
-
HTML Col Tag - Javatpoint
-
HTML Col Tag And Element - HTML Tutorials - W3resource
-
HTML 4 Col Tag
-
HTML Col Tag - Learn HTML | W3Docs
-
HTML Col Tag
-
HTML Col Tag