Layout Properties

There are many properties that help set the styles of your web pages.

PropertyDescriptionW3 Schools Link
background-colorSets the background color of the elementW3 Schools
border-colorSets the color of the borderW3 Schools
border-widthChanges the border width of an elementW3 Schools
border-styleChanges the style of borderW3 Schools
WidthSets the width of an elementW3 Schools
HeightSets the height of an elementW3 Schools
FloatFloats an element to one side of the pageW3 Schools
MarginGenerates space around an elementW3 Schools

FAQ

  1. What does the border-radius property do?
    • The border-radius property determines the radius of the curves at the corners of the element. A bigger radius makes a bigger, softer curve, and a smaller radius makes a smaller, sharper curve. A radius of zero makes a regular corner. You can read more about this property at W3Schools - CSS3 border-radius property.
  2. What if an element inside the page has a different background color from the body?
    • You can see the answer to this question by adding a background-color rule to the p tag. The paragraphs will have the background color in the rule for the p tag, and the rest of the page will follow the rule for the body tag.
  3. Why does using a width and height property at the same time sometimes stretch out the image?
    • When the width of an image changes, the height must change by the same percentage, otherwise the image will stretch. For example, if you double the width of an image, you must also double the height, or the image will be stretched horizontally. When you only define the width or the height, the computer will automatically change the other property so that the image looks the same.

Found a bug in the documentation? Let us know at support@code.org.

Creative Commons License (CC BY-NC-SA 4.0).

This work is available under a Creative Commons License (CC BY-NC-SA 4.0).

If you are interested in licensing Code.org materials for commercial purposes contact us.