Skip to main content

Modern Markup in JavaScript

JavaScript Fundamentals: Modern Markup


Can you explain the script type attribute used in Modern JavaScript development?

View Answer:
Interview Response: When working with modules, we use the script type attribute in Modern JavaScript.

Technical Response: We use the script type attribute in Modern JavaScript development to create JavaScript Modules. The old HTML standard, HTML4, required a script to have a type. Usually, it was type="text/javascript", but we no longer use that implementation.

Code Example: JavaScript type attribute

<html>
<body>
<script type="text/javascript">
// <-- this is the script type attribute
<!--
document.write('Hello JavaScript!');
//-->
</script>
</body>
</html>

What was the script language attribute used for in web development?

View Answer:
Interview Response: This property displays the language of the script. According to the MDN, we no longer utilize it since it is deprecated.

Technical Response: We use the language attribute to mention the scripting language. Typically, its value equates to JavaScript. Although recent versions of HTML (and XHTML, its successor) have phased out using this attribute. You may still find this in older applications on the web, and we should use it in Modern web applications.

Code Example: JavaScript type attribute

<html>
<body>
<script language="javascript">
// <-- this is the script language attribute
<!--
document.write('Hello JavaScript!');
//-->
</script>
</body>
</html>