Skip to content
Related Articles

Related Articles

Why is colspan not a known native attribute in Angular 2?

View Discussion
Improve Article
Save Article
  • Last Updated : 26 Jun, 2020

In order to understand it, we need to have a clear in-depth knowledge between Document Object Model(DOM) and HyperText Markup Language(HTML).
Basically, DOM is a model of objects and is a logical tree representation of the document whereas HTML is a markup language that we used to build web-pages.
Every HTML attributes have one to one mapping to properties of DOM objects.

Example: First Name

<label for="fname">First Name </label>
<input type="text" id="fname" name="fname" disabled >

So, The above example contains two tags label and input. As we can observe, there is an attribute defined inside the input tag which is “disabled”.
Similarly, if you talk about DOM properties, disabled is also present inside the input object.
But they are cases where some attributes of HTML tags are not available inside the DOM. 
Example: colspan. Like colspan, So when you try to use them for attribute binding in Angular 2+, you will get an error which says “can’t bind to colspan since it isn’t a known property of ‘td’ “.
Similarly, we have some properties which are defined in DOM but are not present in HTML.


<h2 [textContent]="title"></h1>

In order to use them for attribute binding you need to use the following syntax “[attr.colspan]”.

import {Component} from '@angular/core';
<h4> Colspan Usage </h4>
   <td [attr.colspan]="colSpan">First Item </td>
   <td>Second Item</td>
   <td>Third Item </td>
table, tr, td{
border: 1px solid black;
export class ColSpanComponent{


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!