0% found this document useful (0 votes)
58 views

Selectors and Their Syntax Syntax To Write CSS

This document provides a CSS cheatsheet with information on CSS syntax, selectors, properties, and places to write CSS styles. It outlines the basic syntax for writing CSS rules with selectors and properties. It also lists common CSS selectors like element names, classes, IDs, attributes, and the universal selector. Additionally, it shows the three main places to write CSS code: inline styles, internal styles in the <style> element, or an external stylesheet linked via <link>. Finally, it categorizes common CSS properties for text styling, backgrounds, displays, boxes, positioning, lists, and other properties.

Uploaded by

dodomaroc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Selectors and Their Syntax Syntax To Write CSS

This document provides a CSS cheatsheet with information on CSS syntax, selectors, properties, and places to write CSS styles. It outlines the basic syntax for writing CSS rules with selectors and properties. It also lists common CSS selectors like element names, classes, IDs, attributes, and the universal selector. Additionally, it shows the three main places to write CSS code: inline styles, internal styles in the <style> element, or an external stylesheet linked via <link>. Finally, it categorizes common CSS properties for text styling, backgrounds, displays, boxes, positioning, lists, and other properties.

Uploaded by

dodomaroc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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