Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

CSS and JS sample Q

Uploaded by

steveiamid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

CSS and JS sample Q

Uploaded by

steveiamid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CSS and JavaScript Sample Questions

Part I: Write true if the statement is correct, false if it is incorrect.


1. CSS defines presentation of a webpage.
2. JavaScript defines the behavior of webpage.
3. CSS float property is used to move block level HTML element to left or
right of the browser display.
4. JavaScript is a client-side scripting tool.
5. Inline CSS is applied in specific html tag using the style attribute.
6. JavaScript is used to make the web interactive.
7. Class selector is used when a class attribute is applied to an html element.
8. Document.write ( ) is one of the ways to display output using JavaScript.
9. Block level elements in CSS can take border, padding and margin properties.
10.JavaScript can be inserted in head section and body section of HTML
document simultaneously.
Part II: Choose the best answer among the given alternatives
1. Which one of the following is a valid JavaScript identifier?
a. _hello-World c. Hello World
b. $hello_world d. All of the above
2. Which one of the following CSS property value pair is used to remove
underline from anchor tag?
a. Underline:none c. Text-decoration:none
b. U:none d. None
3. Which one of the following javascript expressions yield “2012 EC”?
a. 20+12+”EC” c. 20+12+” “+”EC”
b. 20+” ”+”12EC” d. All of the above
4. What is the correct syntax for referring to external CSS?
a. <stylesheet> c. <style src=”” > </style>
</stylesheet> d. None
b. <link rel”
5. Which CSS property controls the text size?
a. font-size c. text-size
b. text-style d. font-style
6. How do you add a background color for all <h1> elements?
a. h1 {background-color:#FFFFFF;}
b. h1.all {background-color:#FFFFFF;}
c. all.h1 {background-color:#FFFFFF;}
d. None

By Bikila A. Page 1
CSS and JavaScript Sample Questions

7. Which CSS property is used to change the text color of an element?


a. color c. fgcolor
b. text-color d. None
8. What is the correct CSS syntax for making all the <p> elements bold?
a. p {font-weight:bold;}
b. <p style="text-size:bold;">
c. p {text-size:bold;}
d. <p style="font-size:bold;">
9. How do you make each word in a text start with a capital letter?
a. text-transform:capitalize
b. text-style:capitalize
c. You can't do that with CSS
d. transform:capitalize
10.Which property is used to change the font of an element?
a. font-family c. font-style
b. font-weight d. None
11.How do you make the text bold?
a. font-weight:bold; c. style:bold;
b. font:bold; d. None
12.How do you display a border like this:
The top border = 10 pixels
The bottom border = 5 pixels
The left border = 20 pixels
The right border = 1pixel?
a. border-width:10px 1px 5px 20px;
b. border-width:5px 20px 10px 1px;
c. border-width:10px 5px 20px 1px;
d. border-width:10px 20px 5px 1px;
13.Which property is used to change the left margin of an element?
a. margin-left c. indent
b. padding-left d. None
14.How do you make a list that lists its items with squares?
a. list-style-type: square; c. list: square;
b. list-type: square; d. None
15.How do you select an element with id "demo"?
a. #demo c. *demo
b. .demo d. demo

By Bikila A. Page 2
CSS and JavaScript Sample Questions

16.How do you select elements with class name "test"?


a. #test c. *test
b. .test d. test
17.How do you group selectors?
a. Separate each selector with a comma
b. Separate each selector with a space
c. Separate each selector with a plus sign
d. All of the above
18.What is the default value of the position property?
a. static c. absolute
b. fixed d. relative
19.How do you insert a comment in a CSS file?
a. // this is a comment c. ' this is a comment
b. /* this is a comment */ d. // this is a comment //
20.Which is the correct CSS syntax?
a. {body:color=black;} c. body {color: black;}
b. {body;color:black;} d. body:color=black;
21.Which HTML attribute is used to define inline styles?
a. styles c. style
b. font d. class
22.Which HTML tag is used to define an internal style sheet?
a. <style> c. <script>
b. <css> d. None
23.Where in an HTML document is the correct place to refer to an external
style sheet?
a. In the <body> section
b. In the <head> section
c. At the end of the document
d. None
24.Inside which HTML element do we put the JavaScript?
a. <script> c. <js>
b. <javascript> d. <scripting>
25.What is the correct JavaScript syntax to change the content of the HTML
element below?
<p id="demo">This is a demonstration.</p>
a. document.getElementById("p").innerHTML = "Hello World!";
b. document.getElement("p").innerHTML = "Hello World!";
c. #demo.innerHTML = "Hello World!";
By Bikila A. Page 3
CSS and JavaScript Sample Questions

d. document.getElementById("demo").innerHTML = "Hello World!";


26.Where is the correct place to insert a JavaScript?
a. Both the <head> section and the <body> section
b. The <body> section
c. The <head> section
d. None
27.What is the correct syntax for referring to an external script called "xxx.js"?
a. <script href="xxx.js"> c. <script src="xxx.js">
b. <script name="xxx.js"> d. None
28.The external JavaScript file must contain the <script> tag.
a. False b. True
29.How do you write "Hello World" in an alert box?
a. alertBox("Hello World");
b. msgBox("Hello World");
c. alert("Hello World");
d. msg("Hello World");
30.How do you create a function in JavaScript?
a. function myFunction() c. function:myFunction()
b. function = myFunction() d. None
31.How do you call a function named "myFunction"?
a. Call myFunction()
b. call function myFunction()
c. myFunction()
d. None
32.How can you add a comment in a JavaScript?
a. //This is a comment c. <!--This is a comment-->
b. 'This is a comment d. None
33.How to insert a comment that has more than one line?
a. /*This comment has c. <!--This comment has
more than one line*/ more than one line-->
b. //This comment has d. None
more than one line//
34.What is the correct way to write a JavaScript array?
a. var colors = (1:"red", 2:"green", 3:"blue")
b. var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue")
c. var colors = ["red", "green", "blue"]
d. var colors = "red", "green", "blue"

By Bikila A. Page 4
CSS and JavaScript Sample Questions

35.JavaScript is the same as Java.


a. False b. True
36.Which event occurs when the user clicks on an HTML element?
a. onclick c. onmouseclick
b. onchange d. onmouseover
37.Is JavaScript case-sensitive?
a. Yes b. No
38.The area between a border and the content of an element is ____
a) margin c) outline
b) clip d) padding
39.Reducing unnecessary interaction of the client with the server is advantage
of___?
a. HTML c. PHP
b. JavaScript d. Script
40.Which style type can be attached and re-used in multiple web files?
a. Inline c. External
b. Embedded d. Internal
Part III: Short Answer and Coding
Use the following HTML code to answer questions 1, 2, 3, 5, 6, 9

1). Write a CSS rule to add an image called ‘logo.jpg’ as a background


2). Write a CSS rule to remove the underline from all the links
3). Write a CSS rule to change the background color of the paragraph tag to blue
and the text color to white.

By Bikila A. Page 5
CSS and JavaScript Sample Questions

4) Write a javascript function which displays “Hello Year Three CS students”


message based on the following information:
a. The function should be written in head section
b. The function should be called in the body section
c. The html page should have one <h1> tag with a welcome message
5) Depending on the HTML code given above, apply the following properties to
the paragraph element:
a. Add a margin of 100px for top, 200px for left, 300pt for right and 100px
for bottom
b. Add a padding of 50px for all sides
c. Add a border style with value double.
6) Depending on the program given above, write a CSS rule to make all the link
tags displayed on separate line.
7) Write a JavaScript program used to display the sum of two numbers based on
the following information:
a. Write the code in body section
b. The code should get the two numbers from user
c. The output should be printed using alert function
8) Write a JavaScript program to display the current date and time.
9) Depending on the program given above, apply the following css rules to the
heading element:
a. Give a width of 300px;
b. Float it to the right direction of the browser screen
10) Write a JavaScript program to convert Fahrenheit degree temperature to
Celsius degree.

By Bikila A. Page 6

You might also like