h1
-h6
, p
, ul
, ol
, li
, script
, a
, title
, span
, div
- void tags (they only have an opening tag):
img
,style
,link
,hr
,meta
width
, height
, color
, background-color
, display
, position
, float
, clear
, @media
, flex
, inline-flex
, justify-content
, align-items
-
<style>internal
: Write the CSS code in the SAME HTML file using the<style></style>
tag.
Example:
p{
color: red;
}
</style> -
external
: Write the CSS code in an external file for examplestyle.css
and we access it with the tag.
Example:
<link rel="stylesheet" href="./style.css"/>
note: Inside the href attribute it might be different depending on your file location! -
inline
: Write the CSS code directly in the tag's attribute section using thestyle
keyword.
Example:
<p style="color: red;>
-
font-size
- 1pt (point) = 1/72nd inch
- 1px = 1/96th inch
- 1em = 100% of parent (meaning if the parent is 20px the element will be 20px too)
- 2em = 200% (meaning if the parent is 20px the element will be 2 x 20px = 40px)
-
display
-
inline
(only takes up as much width as necessary. It does not start on a new line and allows other elements to appear beside it.)
-
inline-block
(make an element behave like an inline and a block-level element. It allows the element to flow inline with surrounding content while maintaining block-level properties, such as setting a specific width and height.) -
flex
-
inline-flex
-
flex
: nowrap
it's NOT responsive, used when we don't want the child flex-items to move to the next line!
-
flex
: wrap
It's opposite tonowrap
, where if the flex-items cant fit in one line because of the screen size, it'll wrap/move the items to the next line! (RESPONSIVE)
- Sets the distribution of the items along the
**main-axis**
Note: to apply this type of CSS, there should be some space left! Meaning the items don't occupy the entire container.
-
justify-content
: flex-start This value will squish everything to theleft/start
side of the container
-
justify-content
: flex-end This value will squish everything to theright/end
side of the container
-
justify-content
: center This value will squish everything to thecenter
of the container
-
justify-content
: space-between
This value will input a space between every element and its adjacent item
- Sets the distribution of the items along the
**cross-axis**
Note: We need to set a height to the container, otherwise we won't see any changes! Another thing is, that flex-wrap has to be set to
nowrap
because it'll affect the behavior! - Sets the distribution of the items along the
-
flex-basis
: ###px (APPLIED TO THE CHILDREN)
This will extend along the main-axis, we add "flex-basis" in the child div -
order
Theorder
is used to change the order of the child flex item!
If only one of the items has the order set to any number greater than 0 then it'll shift to the end.
But of course, if you have more than one child item with an order number > 0, then they will be ordered accordingly
-
align-self
:- Used when we want to change the alignment of a specific item in the container
- Used when we want to change the alignment of a specific item in the container
FLex-Sizing works according to a priority list
Example:
-
Here we have a container that has the display set to flex, so by
default
, the flex-sizing is set to content width unless there's a higher priority that is set.
In case the screen is shrunk, each of the items will automatically shrink until they reach the minimum content size.
Themax-width
: the longest possible line of the text
Themin-width
: the longest word in the text
-
Assigning a specific size to the flex-items:
-
In case we assign a specific size
width
to each item (for example 100px), the item's assigned size will be respected until the overall width of the container gets smaller than the assigned size. If the screen is smaller, the priority goes to the content size/width.
-
In case we use
flex-basis
(recap: determines the width of each of the items), thewidth
will get ignored (again IF there's enough space)
Note: If the screen is shrunk (Phone-Screen),
min-width
will be applied
-
-
position
static
relative
absolute
fixed
-
float
-
clear Used when we need to avoid the style effect "float: left" that the element before has.
-
@media
- @media(max-width: ###px)
BEFORE:
AFTER:
- @media(min-width: ###px)
- @media(min-width: ###px) and (max-width: ###px)
- @media(max-width: ###px) and (min-width: ###px)
- @media
screen(orientation: landscape)
The screen keyword is not necessary by default because it's going to apply to all screens. Where do we use the orientation? It's when we want to target the website whenever it's being printed
- @media(max-width: ###px)
BEFORE: