DEV Community

Raja B
Raja B

Posted on

HTML and CSS Basic

HTML and CSS,
every element is considered a rectangular "box". This concept is known as the CSS Box Model, which determines how elements are sized and spaced on a webpage

The Four Layers of the Box Model

Each box consists of four distinct areas, layered from the inside out: -
Content Box:
The inner area where the actual text, images, or child elements reside -
Padding Box:
The transparent space between the content and the border. It inherits the background of the element. -
Border Box:
A stroke or line that wraps around the padding and content -
Margin Box:
The outermost transparent area that creates space between the element and its neighbors.

Visualization

![CSS Box model] (https://devtouploads.s3.amazonaws.com/uploads/articles/er2utzn5gdvhrcejdche.png)

Key Box Properties

Box Sizing (box-sizing):
-
content-box (Default):

Width and height apply only to the content. Padding and borders are added on top, increasing the element's total size.

  • border-box:

Width and height include content, padding, and border. This makes layout sizing more predictable.

  • Display Types
  • Block Elements:
    Take up the full width available and start on a new line (e.g., <div>, <h1>, <p>).
  • Inline Elements:
    Only take up as much width as necessary and do not start on new lines (e.g., <span>, <a>).What to learn first
Start with these HTML basics:

Page structure: <!DOCTYPE html>, <html>, <head>, <body>.

Text tags:<h1>, <p>, <strong>, <em>.

Links and images: <a>, <img>.

Lists and tables: <ul>, <ol>, <table>.

Forms: <input>, <button>, abel>.

Then learn these CSS basics:

Selectors.

Colors and backgrounds.

Fonts and text styling.

Box model: margin, padding, border.

Layout with Flexbox and Grid.

Responsive design with media queries.

Reference:

Top comments (0)