HTML | colspan Attribute - GeeksforGeeks

Skip to content geeksforgeeks
  • Courses
    • DSA Courses
    • Programming Languages
  • Tutorials
    • Python Tutorial
      • Python Loops and Control Flow
    • Java
      • Java Interview Questions
      • Java Quiz
      • Advance Java
    • Programming Languages
    • System Design
    • Interview Corner
    • Computer Science Subjects
    • DevOps
    • Linux
    • Software Testing
    • Databases
    • Android
    • Excel
    • Mathematics
  • DSA
    • Data Structures
    • Algorithms
      • Analysis of Algorithms
      • Searching Algorithms
      • Sorting Algorithms
    • Practice
      • Company Wise Coding Practice
      • Practice Problems Difficulty Wise
      • Language Wise Coding Practice
      • Curated DSA Lists
    • Company Wise SDE Sheets
    • DSA Cheat Sheets
    • Puzzles
  • Data Science
    • Data Science Packages
    • Data Visualization
    • Data Analysis
  • Web Tech
    • Web Development Using Python
      • Django
      • Flask
    • Cheat Sheets
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App HTML | <td>colspan Attribute Last Updated : 29 Apr, 2019 Summarize Comments Improve Suggest changes Like Article Like Save Share Report Follow

The HTML <td> colspan Attribute is used to specify the number of columns a table should span.

Syntax:

<td colspan="number">

Attribute Values: It contains the numeric value which specifies the number of columns a cell should span.

Example: This Example illustrates the use of colspan attribute in Tabledata Element.

<!DOCTYPE html> <html> <head> <title> HTML <td>colspan Attribute </title> <style> table, th, td { border: 1px solid black; border-collapse: collapse; padding: 6px; } </style> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> HTML <td>colspan Attribute </h2> <table> <tr> <th>Name</th> <th>Expense</th> </tr> <tr> <td>Arun</td> <td>₹10</td> </tr> <tr> <td>Priya</td> <td>₹8</td> </tr> <!-- The last row --> <tr> <!-- This td will span two columns, that is a single column will take up the space of 2 --> <td colspan="2"> Sum: ₹18 </td> </tr> </table> </body> </html>

Output:

Supported Browsers: The browser supported by HTML <td>colspan Attribute are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

M

ManasChhabra2 Follow Improve Previous Article HTML | <tr> charoff Attribute Next Article

Similar Reads

  • HTML | <td>colspan Attribute The HTML <td> colspan Attribute is used to specify the number of columns a table should span. Syntax: <td colspan="number"> Attribute Values: It contains the numeric value which specifies the number of columns a cell should span. Example: This Example illustrates the use of colspan attri 1 min read
  • HTML | <th> colspan Attribute The <th> colspan Attribute in HTML is used to specify a number of columns a header cell should span. Syntax: <th colspan="number"> Attribute Values: It contains single value number which contains the numeric value to sets the number of column a header cell should span. Example: This exam 1 min read
  • HTML | <td> char Attribute The HTML <td> char Attribute is used to specify the alignment to the character of content in a table cell. This attribute only contains char align attribute. Its default value is a decimal point for page language. It is not supported by HTML 5. Syntax: <td char="character"> Attribute Val 1 min read
  • HTML <td> bgcolor Attribute The HTML <td> bgcolor attribute is used to specify the background color of a table cell. It basically, Specify the background color with a hexadecimal code for precise coloring and offers limited color choices compared to modern CSS styling. Note: It is not supported by HTML5.  Syntax:<td b 2 min read
  • HTML <th> char Attribute The HTML <th> char attribute is used to specify the alignment to the character of content in a table header cell. It only contains the char align attribute. Its default value is a decimal point for page language. Note: It is not supported by HTML5. Syntax: <th char="character"> Attribute 1 min read
  • HTML | <col> width Attribute The HTML <col> width Attribute is used to specify the width of a column element. If width attribute is not set then it takes default width according to content. It is not supported by HTML 5. Syntax: <col width="pixels | % | relative_length"> Attribute Values: pixels: It sets the width o 1 min read
  • HTML <table> cellspacing Attribute The cellspacing attribute in HTML is used to define the space between cells in a table. It controls the amount of space, in pixels, between the table cells. This spacing can make the table's content more readable by adding extra room between cells. However, it's important to note that the cellspacin 2 min read
  • HTML <tr> bgcolor Attribute The HTML <tr> bgcolor Attribute is used to specify the background color of a table row. This attribute accepts color values such as color names, hex codes, or RGB values, allowing for easy customization of the background color for individual rows in an HTML table. Note: It is not supported by 2 min read
  • HTML <td> charoff Attribute The HTML <td> charoff attribute specifies the offset for aligning text around a specified character within a table cell. It is used with the char attribute and is now considered obsolete in modern HTML. This attribute can only be used in the char attribute and the align attribute is specified 2 min read
  • HTML | <thead> char Attribute The HTML thead char Attribute is used to specify the alignment to the character of content in a thead Element. This attribute can only be used if the align attribute is set to "char". Its default value is a decimal point for page language. It is not supported by HTML 5. Syntax: <thead char="chara 1 min read
  • HTML | <ol> compact Attribute The HTML <ol> compact attribute is used to define the list should be smaller than the normal by reducing the space between the list items and the indentation of the list. It is a Boolean attribute.Syntax: <ol compact> Note: The HTML <ol> compact attribute is not supported by HTML 5 1 min read
  • HTML <th> bgcolor Attribute The bgcolor attribute in the HTML <th> (table header) tag is used to set the background color of a table header cell. You can specify colors using color names, hexadecimal codes, or RGB values. Note: It is not supported by HTML5. Syntax:<th bgcolor="color_name | hex_number | rgb_number"> 2 min read
  • HTML | <col> span Attribute The HTML <col> span Attribute is used to specify how many numbers of col element should span. Syntax: <col span="number"> Attribute Values: It contains the numeric value which specifies the number of col element should span. Example: C/C++ Code &lt;!DOCTYPE html&gt; &lt;html 1 min read
  • HTML colspan Attribute The colspan attribute in HTML specifies the number of columns a cell should span. It allows the single table cell to span the width of more than one cell or column. It provides the same functionality as "merge cell" in a spreadsheet program like Excel. Note: colspan="0" tells the browser to span the 3 min read
  • HTML | <textarea> cols Attribute The HTML <textarea> cols Attribute is used to tell the browser how many average-width characters should fit on a single line i.e the number of columns to display. It is used to specify the visible width of the <Textarea> Element. Syntax: <textarea cols="number"> Attribute Values: I 1 min read
  • HTML <colgroup> width Attribute The HTML <colgroup> width Attribute is used to specify the width of the colgroup element. The <colgroup> attribute sets a predefined width of the column group. Syntax<colgroup width="pixels|%|relative_lngth">Attribute ValuesValue Description pixels It specify the width of the colgr 1 min read
  • HTML <table> cellpadding Attribute The HTML <table> cell padding Attribute is used to specify the space between the cell content and cell wall. The cellpadding attribute is set in terms of pixels. By default, the padding is set to 0. Note: The <table> cellpadding Attribute is not supported by HTML5. Syntax:<table cellp 1 min read
  • HTML | <col> valign Attribute The HTML <col> valign attribute is used to specify the vertical alignment of the text content in a column element. Syntax: <col valign="top | middle | bottom | baseline"> Attribute Values: top: It sets the content to top-align. middle: It sets the content to middle-align. bottom: It sets 1 min read
  • HTML | <tr> charoff Attribute The HTML tr charoff Attribute is used to sets the number of characters that aligned the characters specified by the char Attribute. This attribute can only be used in the char attribute and align attribute is specified in the tr Element. Syntax: <tr charoff="number"> Attribute Values: number: 1 min read
Article Tags :
  • HTML
  • Web Technologies
  • HTML-Attributes
Like three90RightbarBannerImg Explore More We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy Got It ! Lightbox Improvement Suggest changes Suggest Changes Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal. geeksforgeeks-suggest-icon Create Improvement Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all. geeksforgeeks-improvement-icon Suggest Changes min 4 words, max CharLimit:2000

What kind of Experience do you want to share?

Interview Experiences Admission Experiences Career Journeys Work Experiences Campus Experiences Competitive Exam Experiences

Từ khóa » Html Td Colspan Style