Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:24:01+00:00 2026-06-17T21:24:01+00:00

in HTML <td colspan=3 style=’background-color:pink;’ >hello world</td> but in Javascript / DOM var td

  • 0

in HTML

<td colspan=3 style='background-color:pink;' >hello world</td>

but in Javascript / DOM

var td = document.createElement('td');
td.colSpan = 3;
td.style.backgroundColor = 'pink';

is there a mapping of HTML properties and styles to Javascript/DOM attributes and styles?

understand about camelBack for CSS style

have some HTML specifications, eg, colspan=3, and implementing them with Javascript. so need a mapping between HTML property name and DOM property names.


ok, here’s a mapping for the abnormal properties. those with a 1::1 mapping and functions are omitted.

html2dom = {
  acceptcharset: 'acceptCharset',
  accesskey: 'accessKey',
  bgcolor: 'bgColor',
  cellindex: 'cellIndex',
  cellpadding: 'cellPadding',
  cellspacing: 'cellSpacing',
  choff: 'chOff',
  class: 'className',
  codebase: 'codeBase',
  codetype: 'codeType',
  colspan: 'colSpan',
  datetime: 'dateTime',
  checked: 'defaultChecked',
  selected: 'defaultSelected',
  value: 'defaultValue',
  frameborder: 'frameBorder',
  httpequiv: 'httpEquiv',
  longdesc: 'longDesc',
  marginheight: 'marginHeight',
  marginwidth: 'marginWidth',
  maxlength: 'maxLength',
  nohref: 'noHref',
  noresize: 'noResize',
  noshade: 'noShade',
  nowrap: 'noWrap',
  readonly: 'readOnly',
  rowindex: 'rowIndex',
  rowspan: 'rowSpan',
  sectionrowindex: 'sectionRowIndex',
  selectedindex: 'selectedIndex',
  tabindex: 'tabIndex',
  tbodies: 'tBodies',
  tfoot: 'tFoot',
  thead: 'tHead',
  url: 'URL',
  usemap: 'useMap',
  valign: 'vAlign',
  valuetype: 'valueType' };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:24:02+00:00Added an answer on June 17, 2026 at 9:24 pm

    The DOM IDL exposes different HTML attributes differently for convenience and consistency. That is, COLSPAN -> colSpan and CLASS -> className. (Remember that HTML attributes are not case-sensitive by virtue of being case-normalized while DOM properties are.)

    Since all standard HTML attributes are listed in the appropriate DOM IDL – which is the authoritative source – then a mapping can be generated off of the supplied definitions. Other documentation may need to be consulted for vendor-specific or not-yet-codified attributes.

    The 1.1.3 Naming Conventions says:

    While it would be nice to have attribute and method names that are short, informative, internally consistent, and familiar to users of similar APIs, the names also should not clash with the names in legacy APIs supported by DOM implementations. Furthermore, both OMG IDL and ECMAScript have significant limitations in their ability to disambiguate names from different namespaces that make it difficult to avoid naming conflicts with short, familiar names. So, DOM names tend to be long and descriptive in order to be unique across all environments.

    That is, while the DOM attempts to pair well with HTML (and XML), it favors internal consistency and universal use.


    The original premise of the question was incorrect because background-color is not an HTML attribute. It is a CSS property that is exposed in the DOM via elm.style.backgroundColor (see Jospehn Siber’s answer for the mapping).

    Because background-color is not an HTML attribute it cannot be compared with HTML attributes such as colspan or class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HTML code: <div class=clearfix style=color: #555 style=display:block; > <input type=text id=id_site placeholder=nom-du-site style=width: 245px;
I have the following HTML: <td colspan=23><img src=images/layout_15.gif width=887 height=115></td> But I was wondering
I have the following HTML: <td colspan=23><img src=images/layout_15.gif width=887 height=115></td> But I was wondering
Here is my code: <html> <head> <script type=text/javascript> function displaymessage() { win=window.open(); win.document.write(<html>); win.document.write(<head>);
HTML <!doctype html> <html> <head> </head> <body> <button id=b1 type=button>Show Spoiler</button> <p id=p1 style=display:none>
i try make some parts of page with fixed style. I have similar HTML:
I've got view: @using (Html.BeginForm(ProcessRoute, Calculator)) { @Html.TextBox(CityArrival, null, new { @style = width:
Below is a test HTML file. It displays fine on screen but when I
How can I write this in javascript instead of using the MVC Wrapper? @(Html.Kendo().Grid(Model.List)
In this example I have a main.html template <!DOCTYPE html> <html> <head> <title>Backend</title> <style>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.