w3resource

HTML5: How to define an alternate content for users that do not support client-side scripts?

Go to Exercise page

Solution:

HTML Code:

<!DOCTYPE html><!-- Declares the document type and version of HTML -->
<html><!-- Begins the HTML document -->
<head><!-- Contains metadata about the document -->
<meta charset="utf-8"><!-- Specifies the character encoding of the document -->
<title>How to define an alternate content for users that do not support client-side scripts</title><!-- Sets the title of the document -->
<script><!-- Begins a JavaScript script -->
document.write("w3resource") <!-- Writes "w3resource" to the document -->
</script><!-- Ends the JavaScript script -->
<noscript>Sorry, your browser does not support JavaScript!</noscript><!-- Provides alternative content for users whose browsers do not support JavaScript -->
</head><!-- Ends the head section -->
<body><!-- Contains the content of the document -->
</body><!-- Ends the body section -->
</html><!-- Ends the HTML document -->

Explanation:

  • The HTML document starts with a declaration of its type and version (<!DOCTYPE html>).
  • The <html> element encloses the entire HTML document.
  • The <head> section contains metadata about the document, such as character encoding and title.
  • The <meta charset="utf-8"> tag specifies the character encoding of the document as UTF-8.
  • The <title> tag sets the title of the document.
  • Inside the <head> section, a <script> element begins a JavaScript script.
  • The JavaScript code document.write("w3resource") writes "w3resource" to the document.
  • The <noscript> element provides alternative content for users whose browsers do not support JavaScript, displaying the message "Sorry, your browser does not support JavaScript!".
  • The <body> section contains the content of the document, which is currently empty in this example.
  • The HTML document is properly closed with the </html> tag.

Live Demo:

See the Pen noscript-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
Yes Yes Yes Yes Yes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/html-css-exercise/basic/noscript-answer.php