/ / HTML vs CSS vs JavaScript: A Useful Comparison of the 3

HTML vs CSS vs JavaScript: A Useful Comparison of the 3

A document containing HTML, CSS, and JavaScript codes

The main difference between HTML, CSS, and JavaScript is their functions.

👨‍🏫 HTML is an annotation language that describes a document and its data.

🎨 CSS is a styling language that styles elements of an HTML document.

📢 JavaScript is a commanding language that commands the items of an HTML document.

In other words, HTML is the orator, CSS is the stylist, and JavaScript is the commander.

Are they all coding languages?

Yes! They are all coding languages — because they are communicative means to dialog with computers effectively.

In other words, when web browsers read an HTML document, they understand that they are to present the page’s data as described (annotated) with the HTML markups.

Likewise, when the computer reads a CSS document, it understands that it should style selected HTML elements as stated (declared) with the CSS rulesets.

Also, when devices read a JavaScript document, they understand that they are to command an HTML document as programmed (instructed) with the JavaScript statements.

Example of an HTML code

The HTML code in the snippet below describes how the computer should display the Click me! text — that is, as the page’s highest-level heading.

<h1>Click me!</h1>

Example of a CSS code

The CSS code in the snippet below defines how the computer should style the background of the document’s <h1> element.

h1 {
  background-color: lawngreen;
}

Example of a JavaScript code

The JavaScript code in the snippet below commands the computer to display an alert whenever the document’s <h1> element gets clicked.

document.
getElementsByTagName("h1")[0].
addEventListener(
  "click", () => alert("Hello there 👋!")
);

Try it on CodePen

Note

  • Apart from the three languages discussed above, you can use several other computing languages to communicate with computers.
  • Amongst HTML, CSS, and JavaScript, JavaScript is the only programming language — because it is the only one used to write a series of instructions for computers to execute.
  • CSS does not support all units. See the supported ones in this article.

In summary

HTML, CSS, and JavaScript are all coding languages computers use to present, style, and command a document’s data. They are an essential linguistic system that makes it possible for humans to relate easily to computers. While also making it possible for computers to communicate with one another.

Credit

Featured Image by Bharat Patil

Get Helpful Resources in Your Inbox

A CodeSweetly Digest

Similar Posts