There are two types of HTML elements according to CSS

INLINE elements & BLOCK elements.

Inline elements means that content can flow around the left and right of the elements.

Block elements means that it takes up the line, and we won’t see anything on the left or right side.

A block-level element always starts on a new line.

A block-level element always takes up the full width available (stretches out to the left and right as far as it can).

A block level element has a top and a bottom margin, whereas an inline element does not.

Inline elements are img and span tags. By default, multiple elements, like images or spans can occupy the same line.

An inline element does not start on a new line. An inline element, like the span tag only takes up as much width as necessary.

Block elements, like p and div tags will occupy their own line.

We can change the behaviour of inline/block elements with CSS using the display property. The display property allows you to choose the type of box of that element. CSS renders all elements on the page as a rectangular box. This is called the box model.

I think the best thing to do when you are making websites is to temporarily put a border around all of your elements. This makes it much easier to see what’s going on in your CSS: which elements are taking up the whole width of the page (block) and which are only taking up as much space as the content within them (inline).

But you can probably intuit that webpage are boxy in general, in that content often takes up a kind of rectangular area of the browser.

So what’s important here is that we can tell the HTML element, using CSS, to override its inherent display mode.

So if its an inline element we can tell it to display block, and if its a block element, we can tell it to display inline.

The box model has four different properties:

You can think about a box like a picture frame. There’s the picture itself, then the matting around it, the frame, the space between other picture frames.

Always include this at the top of your CSS files:

html {
	box-sizing: border-box;
*, *:before, *:after {
	box-sizing: inherit;

on positioning...

The position property specifies the type of positioning method used for an element.

There are five different position values:

Elements are then positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. They also work differently depending on the position value.


HTML elements are positioned static by default. Static positioned elements are not affected by the top, bottom, left, and right properties.

An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page.


An element with position: relative; is positioned relative to its normal position.

Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content will not be adjusted to fit into any gap left by the element.


An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element.

A fixed element does not leave a gap in the page where it would normally have been located.


An element with position: absolute; is positioned relative to the nearest positioned parent (instead of positioned relative to the viewport, like fixed).