PrepAway - Latest Free Exam Questions & Answers

Which value should you use?

You are developing an HTML5 page. The page includesthe following code.

The inner paragraph must be exactly 15 pixels from the top left corner of the outer paragraph. You setthe left style for the inner paragraph to the appropriate value.
You need to set the position property of the inner paragraph.
Which value should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
absolute

B.
static

C.
fixed

D.
relative

18 Comments on “Which value should you use?

  1. steve says:

    An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is :




    0



    0
  2. Jeff says:

    For example, with the code below, the normal flow of elements would position div1 on the page first then div2 next to it, div3 next to div2, and div4 next to div3, and all four div elements would be placed inside the article element:

    One
    Two
    Three
    Four

    These blocks all have the default CSS position value of static. You can take any of these blocks out of the normal flow by changing their position property to relative, absolute, or fixed.

    If you set position to relative, you can use the top, right, bottom, and left properties to position the block relative to the position it would have been in. All other blocks stay in the same position they would have been in, as if the block was statically rather than relatively positioned.

    position: relative;
    top: -10px; // Top edge of block moved up 10 pixels from normal
    left: 10px; // Left edge of block moved right 10 pixels from normal

    If you set position to absolute, the block is taken completely out of the normal flow and positioned relative to the edges of its containing block. In the following styling, if div2 were absolutely positioned, div3 would be positioned next to div1 in the normal flow.

    position: absolute;
    top: 25px; // Top edge of block 25 pixels down from top edge of container
    right: 10px; // Right edge of block 10 pixels left from right edge of container




    0



    0
  3. And says:

    The correct answer is A.
    You need to use absolute to be exacly 15 pixels from the outer .
    If you use relative you are going to be 15 pixels from its normal position.

    Don’t you trust me? Just make a test:

    p#inner{
    position: absolute
    top: 0px
    }

    You will see the inner in the same place as the outer , so using 15px the inner will be exacly 15px FROM outer .




    1



    0
  4. some random dude from interwebs says:

    doh, need more info, too much assumptions.
    wtf is ‘left style’ and ‘appropriate value’?

    i know what to stick into ‘appropriate value’ to move it by 15px with relative, absolute, fixed and static position.

    very stupid question.




    0



    0
  5. Carri says:

    http://www.w3schools.com/cssref/pr_class_position.asp

    “Absolute: The element is positioned relative to its first positioned (not static) ancestor element”
    “Relative: The element is positioned relative to its normal position, so “left:20″ adds 20 pixels to the element’s LEFT position”

    The answer sais that “The inner paragraph must be exactly 15 pixels from the top left corner of the outer paragraph” so correct answer is Absolute.




    2



    0

Leave a Reply