Q
How can you hide an HTML element using JavaScript by modifying its display property in an external CSS file?

Answer & Solution

Answer: Option B
Solution:
You can hide an HTML element using JavaScript by modifying its display property in an external CSS file. For example, define a CSS class in the external file with display: none; and apply this class to the element to hide it.
Related Questions on Average

Which property is commonly used in JavaScript to hide an HTML element without removing its space in the layout?

A). visibility

B). hidden

C). display

D). none

How can you hide an HTML element using JavaScript by modifying its CSS display property?

A). element.style.visibility = 'hidden';

B). element.display = 'none';

C). element.style.display = 'none';

D). element.style.display = 'hidden';

How can you hide an HTML element using JavaScript without affecting its layout position?

A). element.style.display = 'none';

B). element.style.visibility = 'hidden';

C). element.style.position = 'absolute';

D). element.style.opacity = '0';

How can you hide an HTML element using JavaScript by toggling its visibility state?

A). element.style.display = 'none';

B). element.style.visibility = 'hidden';

C). element.style.visibility = 'toggle';

D). element.toggle('hidden');

What does setting the CSS visibility property to 'hidden' do to an HTML element?

A). It completely removes the element from the layout.

B). It hides the element without affecting its layout position.

C). It makes the element transparent but still visible.

D). It disables the element but keeps it visible in the layout.

How can you hide an HTML element using JavaScript by modifying its visibility property?

A). element.style.display = 'none';

B). element.visibility = 'hidden';

C). element.style.visibility = 'hidden';

D). element.style.display = 'hidden';

How can you hide an HTML element using JavaScript by setting its display property to 'none' in an external CSS file?

A). element.style.display = 'none';

B). Link the HTML file to an external CSS file with a class that sets display: none;.

C). Import the external CSS file using JavaScript and apply it to the element.

D). element.display = 'none';

What is the advantage of using the classList property to hide HTML elements compared to directly modifying CSS properties?

A). It allows for more granular control and better readability.

B). It provides better performance and faster execution.

C). It simplifies code structure and improves cross-browser compatibility.

D). It increases code complexity and maintenance.

How can you hide multiple HTML elements using JavaScript by adding a CSS class with hidden properties?

A). element.style.display = 'none';

B). element.classList.add('hidden');

C). element.style.visibility = 'hidden';

D). element.style.display = 'block';

Which JavaScript method is commonly used to hide an HTML element by adding a CSS class with hidden properties?

A). element.style.visibility = 'hidden';

B). element.classList.add('hidden');

C). element.style.display = 'none';

D). element.classList.toggle('hidden');