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 | <th> colspan Attribute Last Updated : 01 Aug, 2022 Summarize Comments Improve Suggest changes Like Article Like Save Share Report Follow

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 example illustrates the use of colspan attribute in <th> tag.

html

<!DOCTYPE html> <html> <head> <title>HTML 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 &lt;th&gt;colspan Attribute</h2> <table> <tr> <th colspan="2">Expense</th> </tr> <tr> <td>Arun</td> <td>$10</td> </tr> <tr> <td>Priya</td> <td>$8</td> </tr> </table> </body> </html>

Output:

Supported Browsers: The browser supported by HTML <th>colspan attribute are listed below:

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer
  • Firefox 1 and above
  • Opera
  • Safari
Comment More info Next Article JavaScript Symbol hasInstance Property

M

ManasChhabra2 Follow Improve Article Tags :
  • HTML
  • Web Technologies
  • HTML-Attributes

Similar Reads

  • Cloning an Object with Lodash Cloning an object refers to creating a copy of an existing object. This is particularly useful in JavaScript to avoid unintentional mutations of the original object. Lodash provides various methods for cloning objects, allowing for shallow or deep copies depending on the use case. Below are the foll 3 min read
  • HTML DOM cloneNode() Method The HTML DOM cloneNode() Method is used to copy or clone a node on which the cloneNode() method is called. For example, a list item can be copied from one list to another using this method.Syntax: yourNode.cloneNode([deep]) Parameters: The [deep] is an optional argument. We can set its value to "tru 3 min read
  • How to clone array in ES6 ? The spread operator in ES6 is used to clone an array, whereas the slice() method in JavaScript is an older way that provides 0 as the first argument. These methods create a new, independent array and copy all the elements of oldArray to the new one i.e. both these methods do a shallow copy of the or 2 min read
  • Node.js Buffer.copy() Method Buffer is a temporary memory storage that stores the data when it is being moved from one place to another. It is like an array of integers. The Buffer.copy() method simply copies all the values from the input buffer to another buffer. Syntax: buffer.copy( target, targetStart, sourceStart, sourceEnd 2 min read
  • What are Closures in JavaScript ? JavaScript closures involve the combination of functions and the scope in which they are defined. A closure allows a function to access variables from its scope, outer function scope, and the global scope. This creates a "closed-over" environment, preserving the state of the outer function even afte 1 min read
  • How to Create a Copy of an Object ? In JavaScript, there are several methods to create a copy of an object, each with its own characteristics: Table of Content Using Object.assign()Using the Spread Syntax (...)Using JSON.parse() and JSON.stringify() for Deep CloningUsing Libraries like Lodash for CloningUsing Object.assign()In this Ob 1 min read
  • Backbone.js clone Collection The Backbone.js clone Collection is a function used to form a new instance of the collection with an identical list of models. This method returns a copy of the collection and initiates a new instance of the collection with its list of models. Syntax: collection.clone() ; Parameters: This method doe 2 min read
  • Backbone.js clone Model In this article, we will discuss the Backbone.js clone model. The Backbone.js clone is used to provide a copy from the given model. we can also copy the model to another using clone() method. Syntax: Backbone.Model.clone() Note: It takes no parameters. Example 1: In this example, we will copy the bo 2 min read
  • HTML DOM Range cloneRange() Method The cloneRange() method is used to make a clone of original range and returns that cloned Range object it into a new variable. Note: Change in either Range does not affect the other Range. Syntax: newRange = originalRange.cloneRange(); Parameters: This method does not accept any parameter. Return Va 1 min read
  • How to create an object with prototype in JavaScript ? In this article, we will discuss object creation & prototypes, along with understanding the different ways for object creation & their implementation through the examples. Prototypes are the mechanism by which objects in JavaScript inherit features from another object. A prototype property i 4 min read
  • How to get the Class Name of an Object in JavaScript In this article, we will learn how we can get the class Name of an Object with multiple approaches in JavaScript. In JavaScript, determining an object's class name can be done using multiple approaches. The constructor property of an object reveals the function that created it, while the instanceof 3 min read
  • JavaScript Object entries() Method The Object.entries() method in JavaScript is used to retrieve an array of an object's enumerable property [key, value] pairs. This method is particularly useful for transforming and iterating over objects in situations where array-like manipulation is needed. Syntax:Object.entries(obj);Parameters:ob 4 min read
  • Interesting Facts about Object in JavaScript Let's see some interesting facts about JavaScript Objects that can help you become an efficient programmer. JavaSctipt Objects internally uses Hashing that makes time complexities of operations like search, insert and delete constant or O(1) on average. It is useful for operations like counting freq 4 min read
  • JavaScript Array copyWithin() Method The Javascript Array.copyWithin() method considers an array first and then copies part of an array to the same array itself and returns it, without modifying its size but yet the modified data whatever user wishes to have in another's place i.e, copies array element of an array within the same array 3 min read
  • How to assign an id to a child tag of the cloned html ? Here we use in basic HTML, CSS, JavaScript, jQuery, and Bootstrap to build this small example project. jQuery is an open-source library that simplifies create and navigation of web applications. We are going to use three jQuery methods such as clone(), append(), and attr() method to solve this examp 3 min read
  • How to iterate over a JavaScript object ? Iteration involves looping through the object's properties one by one. Depending on the method used, you can access and manipulate different levels of properties efficiently. Here are several methods. There are many methods to iterate over an object which are discussed below: Table of Content Using 3 min read
  • JavaScript Reflect set() Method JavaScript Reflect.set() method in JavaScript is used to set the value of an object property. It returns a Boolean value true if the property is successfully set else it returns false. Syntax: Reflect.set(obj, Key, value, receiver) Parameters: This method accepts four parameters as mentioned above a 2 min read
  • How to Copy Array by Value in JavaScript ? There are various methods to copy array by value in JavaScript. 1. Using Spread OperatorThe JavaScript spread operator is a concise and easy metho to copy an array by value. The spread operator allows you to expand an array into individual elements, which can then be used to create a new array. Synt 4 min read
  • JavaScript Object create() Method JavaScript object.create() method is used to create a new object with the specified prototype object and properties. Object.create() method returns a new object with the specified prototype object and properties. Syntax:Object.create(prototype[, propertiesObject])Parameters:prototype: It is the prot 3 min read
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 Colspan Kullanımı