How can you declare a global variable in HTML using the data-* attribute within an HTML element?
A). <div data-global-var='value'> </div>
B). <div global-var='value'> </div>
C). <div data='global-var: value'> </div>
D). <div global data-var='value'> </div>
What is a global variable in HTML?
A). A variable declared inside a function
B). A variable declared outside of any function or block
C). A variable declared within an HTML element
D). A variable declared with the global attribute
Which statement accurately describes the scope of global variables declared in HTML?
A). Global variables are accessible only within the <script> element where they are declared
B). Global variables are accessible only within the <body> element where they are declared
C). Global variables are accessible throughout the entire HTML document
D). Global variables are accessible only within the <head> element where they are declared
What is the purpose of using global variables within HTML elements using custom data attributes?
A). To store and retrieve data specific to each HTML element
B). To restrict access to data within specific HTML elements
C). To create variables with limited scope within HTML elements
D). To avoid using JavaScript for data manipulation
What is the correct syntax for defining a global variable in HTML using the <script> element?
A). <script globalVar='value'>
B). <script var='globalVar' value='value'>
C). <script global var='globalVar' value='value'> </script>
D). <script global='globalVar' value='value'> </script>
How can you access a global data attribute defined in an HTML element using JavaScript?
A). By using the getAttribute() method
B). By using the data() method
C). By using the setDataAttribute() method
D). By using the getGlobalAttribute() method
What is the output of the following HTML code snippet? <br> <br> <script> <br>var globalVar = 'Hello'; <br>console.log(globalVar); <br> </script>
A). Hello
B). Undefined
C). Error
D). 'Hello'
Which HTML element is commonly used to store and access global data attributes in HTML?
A). <form>
B). <body>
C). <head>
D). <html>
Which attribute is used to declare a global variable inside a <script> element in HTML?
A). data-global
B). global
C). globalvar
D). name
What is the purpose of using the defer attribute in a <script> element in HTML?
A). To delay the loading of the script until after the HTML content is parsed
B). To prevent the script from executing unless triggered manually
C). To execute the script asynchronously
D). To specify the script's global variables