250+ TOP MCQs on Scripting CSS and Answers

Javascript Multiple Choice Questions on “Scripting CSS”.

1. Which syntax is used to describe elements in CSS?
a) Protectors
b) Selectors
c) Both Protectors and Selectors
d) Protectors or Selectors

Answer: b
Clarification: CSS stylesheets have a very powerful syntax, known as selectors, for describing elements or sets of elements within a document.

2. What does the following JavaScript code snippet mean?

a) Span child after log declaration
b) Specific span child of id greater than log
c) Span child less than log
d) Any span child of the element with id as log

Answer: d
Clarification: The above code snippet means that any span child of the element with id=”log”.

3. Which of the following is the ultimate element selection method?
a) querySelectorAll()
b) querySelector()
c) queryAll()
d) query()

Answer: a
Clarification: querySelectorAll() is the ultimate element selection method: it is a very powerful technique by which client-side JavaScript programs can select the document elements that they are going to manipulate.

4. Which of the following is the Web application equivalent to querySelectorAll()?
a) #()
b) &()
c) $()
d) !()

Answer: c
Clarification: Web applications based on jQuery use a portable, cross-browser equivalent to querySelectorAll() named $().

5. The C in CSS stands for _______________
a) Continuous
b) Cascaded
c) Contentional
d) Cascading

Answer: d
Clarification: The C in CSS stands for “cascading”. This term indicates that the style rules that apply to any given element in a document can come from a “cascade” of different sources.

6. The first version of CSS is _____________
a) CSS1
b) CSS2
c) CSS3
d) CSS

  250+ TOP MCQs on Getting Started with R – III and Answers

Answer: c
Clarification: The first version of CSS is CSS1.

7. Which of the following is not an example of a Shortcut Property?
a) border
b) font
c) text
d) value

Answer: d
Clarification: border, font & text are shortcut properties. For example, the font-family, font-size, font-style, and font-weight properties can all be set at once using a single font property with a compound value:

font: bold italic 24pt helvetica;

8. Which of the following is the default positioning elements with CSS?
a) relative
b) static
c) absolute
d) fixed

Answer: b
Clarification: static is the default value and specifies that the element is positioned according to the normal flow of document content (for most Western languages, this is left to right and top to bottom).

9. Which property lays the element according to the normal flow?
a) relative
b) absolute
c) fixed
d) static

Answer: a
Clarification: When the position property is set to relative, an element is laid out according to the normal flow, and its position is then adjusted relative to its position in the normal flow.

10. Which of the following property allows you to specify an element’s position with respect to the browser window?
a) relative
b) fixed
c) static
d) absolute

Answer: b
Clarification: The fixed value allows you to specify an element’s position with respect to the browser window. Elements with fixed positioning are always visible and do not scroll with the rest of the document. Like absolutely positioned elements, fixed-position elements are independent of all others and are not part of the document flow.

  250+ TOP MCQs on Expressions and Operators and Answers

11. What will be the output of the following JavaScript code?

<p id="demo"></p>
<script>
var x = 'It's';
document.getElementById("demo").innerHTML = x ; 
</script>

a) It’s
b) ‘It’s’
c) It’s
d) Error

Answer: c
Clarification: If an apostrophe is present in the string then a backslash is added before it. The string skips the execution of the character after a backslash.

12. What will be the output of the following JavaScript code?

<p id="demo"></p>
<script>
var pos = str.indexOf("locate");
document.getElementById("demo").innerHTML = pos;
</script>

a) 5
b) 7
c) 0
d) Error

Answer: b
Clarification: The indexOf() method returns the position of the first occurrence of a specified text. locate occurs first time at 7 positions.

13. What will be the output of the following JavaScript code?

<button onclick="myFunction()">Try it</button>
<p id="demo">one</p>
<script>
function myFunction() 
{
   var str = document.getElementById("demo").innerHTML; 
   var txt = str.replace("one","two");
   document.getElementById("demo").innerHTML = txt;
}
</script>

a) one
b) two
c) error
d) undefined

Answer: b
Clarification: The replace function replaces string data with a specified value. The innerHtml function changes the value of data in the paragraph.

14. What will be the output of the following JavaScript code?

<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() 
{
   var str = "The rain in SPAIN stays mainly in the plain"; 
   var res = str.match(/z/);
   If(res)
      res=true;
   Else
      res=false;
   document.getElementById("demo").innerHTML = res;
}
</script>

a) True
b) False
c) Error
d) Handling

  250+ TOP MCQs on Invocation of the Performance Object and Answers

Answer: b
Clarification: The match method finds for a match in the given string. Since z is not present in the string, the output will be false.

15. What will be the output of the following JavaScript code?

<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() 
{
   var str = "a,b,c,d,e,f";
   var arr = str.split(",");
   document.getElementById("demo").innerHTML = arr[3];
}
</script>

a) d
b) a
c) b
d) c

Answer: a
Clarification: The split function splits the string according to the argument passed to it. The third index of the array will be initialized with d, hence the output will be d.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top