The DOM style columnspan property is used to specify how many columns an element should span across.
Syntax:
- It return the columnSpan property:
object.style.columnSpan
- It set the columnSpan property:
object.style.columnSpan = "1|all|initial|inherit"
Property Values:
- 1: Default value of the element. Used to span element one column.
- all: It is used to span element to all column.
- initial: It is used to set its Default value.
- inherit: It is used to set property from its parent.
Return value: This property returns a String, that represent the column-span property of an element.
Example-1: Set columnSpan property to “all”.
html
<!DOCTYPE html> < html >
< head >
< title >
HTML | DOM Style columnSpan Property
</ title >
< style >
#main {
column-count: 3;
/* Standard syntax */
}
</ style >
</ head >
< body >
< center >
< h1 style="color:green;">GeeksForGeeks</ h1 >
< h3 >DOM Style columnSpan Property </ h3 >
< button onclick="geeks()">Click</ button >
< div id="main">
< h2 id="h2tag">
It is a good platform to learn programming.
</ h2 >
Prepare for the Recruitment drive of product
based companies like Microsoft, Amazon,
Adobe etc with a free online placement
preparation course. The course focuses
on various MCQ's & Coding question likely
to be asked in the interviews & make your
upcoming placement season efficient and
successful.
</ div >
< script >
function geeks() {
// Code for old Chrome, Safari, Opera
document.getElementById("h2tag").style.WebkitColumnSpan =
"all";
// For other standard browsers.
document.getElementById("h2tag").style.columnSpan = "all";
}
</ script >
</ center >
</ body >
</ html >
|
Output: Before click on the Button:
After click on the Button:
Example-2: Set columnSpan property to “all”.
html
<!DOCTYPE html> < html >
< head >
< title >
HTML | DOM Style columnSpan Property
</ title >
< style >
#main {
column-count: 3;
/* Standard syntax */
border: 2px solid green;
}
#h2tag {
background-color: orange;
color: lime;
}
</ style >
</ head >
< body >
< center >
< h1 style="color:green;">GeeksForGeeks</ h1 >
< h3 >DOM Style columnSpan Property </ h3 >
< button onclick="geeks()">Click</ button >
< br >
< div id="main">
< h2 id="h2tag">
GeeksforGeeks is a good platform to learn
programming.
</ h2 >
It is a good platform to learn programming.
It is an educational website. Prepare for
the Recruitment drive of product based
companies like Microsoft, Amazon, Adobe
etc with a free online placement preparation
course. The course focuses on various MCQ's &
Coding question likely to be asked in the
interviews & make your upcoming placement
season efficient and successful. Also, any
geeks can help other geeks by writing articles
on the GeeksforGeeks, publishing articles follow
few steps that are Articles that need little
modification/improvement from reviewers are
published first. To quickly get your articles
reviewed, please refer existing articles, their
formatting style, coding style, and try to make
you are close to them. In case you are a beginner,
you may refer Guidelines to write an Article
</ div >
< script >
function geeks() {
// Code for old Chrome, Safari, Opera
document.getElementById("h2tag").style.WebkitColumnSpan
= "all";
// For other standard browsers.
document.getElementById("h2tag").style.columnSpan
= "all";
}
</ script >
</ center >
</ body >
</ html >
|
Output: Before click on the Button:
After click on the Button:
Supported Browser: The browser supported by HTML | DOM Style columnSpan Property are listed below:
- Google Chrome 50.0 and above
- Edge 12 and above
- Internet Explorer 10.0 and above
- Opera 11.1 and above
- Firefox 71.0 and above
- Safari 9.0