Sonzaschool
Rudi

Sekondari ya Kawaida · Kidato cha Pili · Amali · Electronics and Computer

Computer Programming

Implementing the box model in CSS

takriban dakika 3 kusoma

Majadiliano
Mada za sehemu hiiFormatting web pages with Cascading Style Sheets (CSS)Mada 5

The CSS box model describes how every HTML element is rendered as a rectangular box, made up of four layers: content, padding, border, and margin. Understanding how these layers work together helps you control the spacing, size, and appearance of elements on a web page.

1. Content

The content area is where your text, images, or other inner elements appear. You control its size using the width and height properties.

div {
  width: 200px;
  height: 150px;
}

2. Padding

Padding creates space inside the border, between the content and the border edge. It pushes the content away from the box edges.

div {
  padding: 20px;
}

You can also set padding for each side individually:

  • padding-top, padding-right, padding-bottom, padding-left

3. Border

The border surrounds the padding (or content if there is no padding). You can set its width, style, and color.

div {
  border: 3px solid #0066cc;
}

Common border styles include solid, dashed, dotted, and double.

4. Margin

Margin creates space outside the border, separating the box from neighboring elements.

div {
  margin: 15px;
}

Like padding, you can set margins for each side individually: margin-top, margin-right, margin-bottom, margin-left.

Jinsi utakavyotathminiwaTathmini ya mchakato · Tathmini ya matokeo · Tathmini ya maarifa

Tathmini ya mchakato

  • Set width and height of elements.
  • Apply padding, margin, and border.
  • Test and adjust spacing between elements.
  • Use box sizing property.
  • Preview and verify box model implementation.

Tathmini ya matokeo

Web pages with a box model employing CSS are implemented correctly.

Tathmini ya maarifa

Methods used: The student should explain how to:

  • implement the CSS box model.

Principles: The student should explain the principle of:

  • spacing and boxsizing.

Theories: The student should explain:

  • CSS box model structure

Circumstantial knowledge:

Detailed knowledge about:

  • border styles and effects.

Swali

Which of the following lists the four layers of the CSS box model in the correct order, from innermost to outermost?

Ingia ili kuwasilisha jibu lako na lihesabiwe katika umahiri wako.

Ingia ili kufanya mazoezi

Mwalimu

Umekwama? Niulize chochote kuhusu mada hii.

Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu swali hili.

Ingia ili kuuliza

Majadiliano

Hakuna maswali bado

Ingia ili kuuliza
Inapakia majadiliano…