HTML and CSS Reference
In-Depth Information
Answers
This section contains the solutions to the thought experiments and answers to the objective
review questions in this chapter.
Objective 4.1: Thought experiment
jQuery is the easiest way to achieve changing CSS styles dynamically. JavaScript will do the
trick as well. All the CSS properties that have been looked at are available to be changed dy-
namically. So for example, in the following code, the color of the button is changed to green
when it is clicked:
<html>
<head>
<script src="jquery-2.0.3.min.js" type="text/javascript"></script>
<script>
$("document").ready(function () {
$("#changeStyle").click(function () {
$(this).css("color", "green");
});
});
</script>
</head>
<body>
<button id="changeStyle">Change Style</button>
</body>
</html>
Objective 4.1: Review
Correct answer: B
1.
Incorrect : font-style: italic will display the text with italics.
A.
Correct : font-weight: heavy; heavy is not a valid option for font-weight.
B.
Incorrect : font: bolder 12px arial; is a valid shorthand for setting font attributes.
C.
Incorrect : color: green; is a valid way to change the color of the text to green.
D.
Correct answer: D
2.
Incorrect: Right will align all the text to the right side of the box.
A.
Incorrect: Full is not a valid option.
B.
Incorrect: Center will align the text along the center of the box.
C.
Correct: Justify will align the text such that each line takes up the width of the box.
D.
 
Search WWH ::




Custom Search