You are on page 1of 1

CSS Cheatsheet

1 Syntax to write CSS 3 Selectors and their syntax


Basic Selectors Combinators Pseudo Selectors
Selectors selectors {
The element(s) on which the style should be applied elementname selectorA + selectorB Adjacent sibling :active
....property: value;
.classname selectorA ~ selectorB General sibling :hover
Property and its value }
#idname parent > child Direct child :visited
This is the actual style to be applied to the element(s)
[attr=value] parent descendent Descendent :focus
*
2 3 places to write CSS 4 Common CSS properties (by group) margin

border
(A) Inline styles
TEXT: BACKGROUND: padding
<element style="property: value;"> color background
content
font background-attachment
(B) In the <style> element font-family background-color
font-size background-image
<head> font-weight background-position
....<style> letter-spacing background-repeat
........ selectors { property: value; } line-height
text-align DISPLAY: BOX: POSITION:
....</style>
text-decoration display border position
</head>
text-indent float border-color top
text-transform clear border-style bottom
(C) In a dedicated file (style.css)
vertical-align overflow border-width left
& refer that file via the <link> element
visibility height right
<head> LIST: margin z-index

....<link rel="stylesheet" list-style OTHER: padding


list-style-image cursor width
........ href="style.css" />
list-style-position box-sizing
</head>
list-style-type

You might also like