

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why is JavaScript case sensitive but HTML isn't?
A script is in plain text and not just markup like HTML, which is case insensitive. In JavaScript, the while keyword should be "while", not "While" or "WHILE". Case sensitivity is important since it is closely related to HTML, but some methods and events are mentioned differently. JavaScrip has a strict syntax to process the client-side-scripts written in JavaScript.
Some tags and attributes in HTML have the same name as JavaScript objects and properties. In HTML, the attribute and tag names are case-insensitive. The close association of HTML and JavaScript can lead to confusion, so case sensitivity is more important in JavaScript. For example, HTML onclick event attribute is mentioned as onClick in HTML but should be onclick in JavaScript.
The following two words in JavaScript are completely different:
var demo; var DEMO;
The following are different object due to the case-sensitive features of JavaScript:
function Employee(id, name, subject){ this.id = id; this.name = name; } var employee = new Employee("ee1", “John”,”30”);
While working with JavaScript, do check for capitalization of variable, function and object name. This will prevent syntax and other errors.
- Related Questions & Answers
- Is JavaScript a case sensitive language?
- Case-sensitive sort in JavaScript
- What's a food that people think is healthy but really isn't?
- How to do case-sensitive string comparison in JavaScript?
- Case sensitive string comparison in Java.
- How to create a variable that can be set only once but isn't final in Java?
- Why is case sensitivity so much more important in JavaScript?
- Why does C++ require a cast for malloc() but C doesn't?
- Why JavaScript 'var null' throw an error but 'var undefined' doesn't?
- Why doesn't JavaScript support multithreading?
- How MySQL can perform case-sensitive string comparison?
- Are MySQL database and table names case-sensitive?
- How to achieve case sensitive uniqueness and case insensitive search in MySQL?
- Creating an empty case-sensitive HybridDictionary Class in C#
- What ingredient is added to make syrups of children sweet? Isn’t it harmful?