PrepAway - Latest Free Exam Questions & Answers

Which line of code should you use?

An HTML page contains no embedded JavaScript or CSS code. The body of the page
contains only the following line of code.
<p id=”test”>test</p>
A CSS style sheet must be applied dynamically. The style must visibly change the
appearance of the paragraph on the page.
You need to apply a style the paragraph.
Which line of code should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
document.getElementById(“test”).style.border = “0”;

B.
document.getElementById(“test”).style.position = “static”;

C.
document.getElementById (“test”).style.padding = “15px”;

D.
document.getElementById(“test”).style.top = “5px”;

Explanation:
A: The border shorthand property sets all the border properties in one declaration.
The properties that can be set, are (in order): border-width, border-style, and border-color.
It does not matter if one of the values above are missing, e.g. border:solid #ff0000; is
allowed.

10 Comments on “Which line of code should you use?

  1. freedeveloper says:

    A This is wrong a style with border 0 does not made a “visible” change in the page. because the paragraph has no border.
    B,D are default position in this case that it is the first and only code in the page
    C IS CORRECT, this move the text of the paragraph, 15 px to right and it is visible the change in the page.




    2



    0
  2. Sanjay Soni says:

    test

    // document.getElementById(“test”).style.border = “0”;
    // document.getElementById(“test”).style.position = “static”;
    document.getElementById (“test”).style.padding = “15px”;
    //document.getElementById(“test”).style.top = “5px”;

    tested C is correct.




    1



    0

Leave a Reply