CSS reference
Use this CSS reference to browse an alphabetical index of all of the standard CSS properties, pseudo-classes, pseudo-elements, data types, functional notations and at-rules. You can also browse key CSS concepts and a list of selectors organized by type. Also included is a brief DOM-CSS / CSSOM reference.
Basic rule syntax
Style rule syntax
style-rule ::= selectors-list { properties-list }
... where :
selectors-list ::= selector[:pseudo-class] [::pseudo-element] [, selectors-list] properties-list ::= [property : value] [; properties-list]
See the index of selectors, pseudo-classes, and pseudo-elements below. The syntax for each specified value depends on the data type defined for each specified property.
Style rule examples
strong { color: red; } div.menu-bar li:hover > ul { display: block; }
For a beginner-level introduction to the syntax of selectors, see our guide on CSS Selectors. Be aware that any syntax error in a rule definition invalidates the entire rule. Invalid rules are ignored by the browser. Note that CSS rule definitions are entirely (ASCII) text-based, whereas DOM-CSS / CSSOM (the rule management system) is object-based.
At-rule syntax
As the structure of at-rules varies widely, please see At-rule to find the syntax of the specific one you want.
Index
Note: The property names in this index do not include the JavaScript names where they differ from the CSS standard names.
accent-color:activeadditive-symbols (@counter-style)::after (:after)align-contentalign-itemsalign-selfalign-tracksall<an-plus-b><angle><angle-percentage>animationanimation-delayanimation-directionanimation-durationanimation-fill-modeanimation-iteration-countanimation-nameanimation-play-stateanimation-timing-function@annotationannotation():any-linkappearanceascent-override (@font-face)aspect-ratioattr()
::backdropbackdrop-filterbackface-visibilitybackgroundbackground-attachmentbackground-blend-modebackground-clipbackground-colorbackground-imagebackground-originbackground-positionbackground-position-xbackground-position-ybackground-repeatbackground-size<basic-shape>::before (:before):blankbleed (@page)<blend-mode>block-overflowblock-sizeblur()borderborder-blockborder-block-colorborder-block-endborder-block-end-colorborder-block-end-styleborder-block-end-widthborder-block-startborder-block-start-colorborder-block-start-styleborder-block-start-widthborder-block-styleborder-block-widthborder-bottomborder-bottom-colorborder-bottom-left-radiusborder-bottom-right-radiusborder-bottom-styleborder-bottom-widthborder-collapseborder-colorborder-end-end-radiusborder-end-start-radiusborder-imageborder-image-outsetborder-image-repeatborder-image-sliceborder-image-sourceborder-image-widthborder-inlineborder-inline-colorborder-inline-endborder-inline-end-colorborder-inline-end-styleborder-inline-end-widthborder-inline-startborder-inline-start-colorborder-inline-start-styleborder-inline-start-widthborder-inline-styleborder-inline-widthborder-leftborder-left-colorborder-left-styleborder-left-widthborder-radiusborder-rightborder-right-colorborder-right-styleborder-right-widthborder-spacingborder-start-end-radiusborder-start-start-radiusborder-styleborder-topborder-top-colorborder-top-left-radiusborder-top-right-radiusborder-top-styleborder-top-widthborder-widthbottom@bottom-centerbox-decoration-breakbox-shadowbox-sizingbreak-afterbreak-beforebreak-insidebrightness()
calc()caption-sidecaret-color@character-variantcharacter-variant()@charset:checkedcircle()clamp()clearclipclip-path<color>colorcolor-adjustcolor-schemecolumn-countcolumn-fillcolumn-gapcolumn-rulecolumn-rule-colorcolumn-rule-stylecolumn-rule-widthcolumn-spancolumn-widthcolumnsconic-gradient()containcontentcontent-visibilitycontrast()<counter>counter-incrementcounter-resetcounter-set@counter-stylecounters()cross-fade()cubic-bezier()::cue::cue-region:currentcursor<custom-ident>length#chlength#cm
angle#deg:default:defineddescent-override (@font-face)<dimension>:dirdirection:disableddisplay<display-box><display-inside><display-internal><display-legacy><display-listitem><display-outside>drop-shadow()resolution#dpcmresolution#dpiresolution#dppx
fallback (@counter-style)filter<filter-function>:first:first-child::first-letter (:first-letter)::first-line (:first-line):first-of-typefit-content()<flex>flexflex-basisflex-directionflex-flowflex-growflex-shrinkflex-wrapflex_value#frfloat:focus:focus-visible:focus-withinfontfont-display (@font-face)@font-facefont-familyfont-family (@font-face)font-feature-settingsfont-feature-settings (@font-face)@font-feature-valuesfont-kerningfont-language-overridefont-optical-sizingfont-sizefont-size-adjustfont-stretchfont-stretch (@font-face)font-stylefont-style (@font-face)font-synthesisfont-variantfont-variant (@font-face)font-variant-alternatesfont-variant-capsfont-variant-east-asianfont-variant-ligaturesfont-variant-numericfont-variant-positionfont-variation-settingsfont-variation-settings (@font-face)font-weightfont-weight (@font-face)forced-color-adjustformat()<frequency><frequency-percentage>:fullscreen:future
angle#gradgap<gradient>::grammar-errorgrayscale()gridgrid-areagrid-auto-columnsgrid-auto-flowgrid-auto-rowsgrid-columngrid-column-endgrid-column-startgrid-rowgrid-row-endgrid-row-startgrid-templategrid-template-areasgrid-template-columnsgrid-template-rows
frequency#Hzhanging-punctuation:hasheightheight (@viewport)@historical-forms:host():host-context():hoverhsl()hsla()hue-rotate()hyphens
<ident><image>image()image-orientationimage-renderingimage-resolutionimage-set()@import:in-range:indeterminateinheritinherits (@property)initialinitial-letterinitial-letter-aligninitial-value (@property)inline-sizeinsetinset()inset-blockinset-block-endinset-block-startinset-inlineinset-inline-endinset-inline-start<integer>:invalidinvert():isisolationlength#in
:lang:last-child:last-of-typeleader():leftleft@left-bottom<length><length-percentage>letter-spacingline-breakline-clampline-gap-override (@font-face)line-heightline-height-steplinear-gradient():linklist-stylelist-style-imagelist-style-positionlist-style-typelocal():local-link
length#mmmarginmargin-blockmargin-block-endmargin-block-startmargin-bottommargin-inlinemargin-inline-endmargin-inline-startmargin-leftmargin-rightmargin-topmargin-trim::markermarks (@page)maskmask-bordermask-border-modemask-border-outsetmask-border-repeatmask-border-slicemask-border-sourcemask-border-widthmask-clipmask-compositemask-imagemask-modemask-originmask-positionmask-repeatmask-sizemask-typemasonry-auto-flowmath-stylematrix()matrix3d()max()max-block-sizemax-heightmax-height (@viewport)max-inline-sizemax-linesmax-widthmax-width (@viewport)max-zoom (@viewport)@mediamin()min-block-sizemin-heightmin-height (@viewport)min-inline-sizemin-widthmin-width (@viewport)min-zoom (@viewport)minmax()mix-blend-modetime#ms
@namespacenegative (@counter-style):not:nth-child:nth-col:nth-last-child:nth-last-col:nth-last-of-type:nth-of-type<number>
object-fitobject-positionoffsetoffset-anchoroffset-distanceoffset-pathoffset-positionoffset-rotate:only-child:only-of-typeopacityopacity():optionalorderorientation (@viewport)@ornamentsornaments()orphans:out-of-rangeoutlineoutline-coloroutline-offsetoutline-styleoutline-widthoverflowoverflow-anchoroverflow-blockoverflow-clip-marginoverflow-inlineoverflow-wrapoverflow-xoverflow-yoverscroll-behavioroverscroll-behavior-blockoverscroll-behavior-inlineoverscroll-behavior-xoverscroll-behavior-y
Pseudo-classesPseudo-elementslength#pclength#ptlength#pxpad (@counter-style)paddingpadding-blockpadding-block-endpadding-block-startpadding-bottompadding-inlinepadding-inline-endpadding-inline-startpadding-leftpadding-rightpadding-top@pagepage-break-afterpage-break-beforepage-break-insidepaint()paint-order::part:pastpath():paused<percentage>perspectiveperspective()perspective-origin:picture-in-pictureplace-contentplace-itemsplace-self::placeholder:placeholder-shown:playingpointer-eventspolygon()<position>positionprefix (@counter-style)@property
angle#radlength#remradial-gradient()range (@counter-style)<ratio>:read-only:read-writerect()repeat()repeating-linear-gradient()repeating-radial-gradient():requiredresize<resolution>revertrgb()rgba():rightright@right-bottom:rootrotaterotate()rotate3d()rotateX()rotateY()rotateZ()row-gapruby-alignruby-mergeruby-position
saturate()scalescale()scale3d()scaleX()scaleY()scaleZ():scopescroll-behaviorscroll-marginscroll-margin-blockscroll-margin-block-endscroll-margin-block-startscroll-margin-bottomscroll-margin-inlinescroll-margin-inline-endscroll-margin-inline-startscroll-margin-leftscroll-margin-rightscroll-margin-topscroll-paddingscroll-padding-blockscroll-padding-block-endscroll-padding-block-startscroll-padding-bottomscroll-padding-inlinescroll-padding-inline-endscroll-padding-inline-startscroll-padding-leftscroll-padding-rightscroll-padding-topscroll-snap-alignscroll-snap-stopscroll-snap-typescrollbar-colorscrollbar-gutterscrollbar-width::selectionselector()sepia()<shape>shape-image-thresholdshape-marginshape-outsidesize (@page)size-adjust (@font-face)skew()skewX()skewY()::slottedspeak-as (@counter-style)::spelling-errorsrc (@font-face)steps()<string>@stylesetstyleset()@stylisticstylistic()suffix (@counter-style)@supports@swashswash()symbols (@counter-style)symbols()syntax (@property)system (@counter-style)time#s
angle#turntab-sizetable-layout:targettarget-counter()target-counters()::target-texttarget-text():target-withintext-aligntext-align-lasttext-combine-uprighttext-decorationtext-decoration-colortext-decoration-linetext-decoration-skiptext-decoration-skip-inktext-decoration-styletext-decoration-thicknesstext-emphasistext-emphasis-colortext-emphasis-positiontext-emphasis-styletext-indenttext-justifytext-orientationtext-overflowtext-renderingtext-shadowtext-size-adjusttext-transformtext-underline-offsettext-underline-position<time><time-percentage><timing-function>top@top-centertouch-actiontransformtransform-box<transform-function>transform-origintransform-styletransitiontransition-delaytransition-durationtransition-propertytransition-timing-functiontranslatetranslate()translate3d()translateX()translateY()translateZ()type()
unicode-bidiunicode-range (@font-face)unset<url>url():user-invaliduser-select:user-validuser-zoom (@viewport)
length#vhlength#vmaxlength#vminlength#vw:validvar()vertical-align@viewportviewport-fit (@viewport)visibility:visited
:wherewhite-spacewidowswidthwidth (@viewport)will-changeword-breakword-spacingword-wrapwriting-mode
Selectors
The following are the various selectors, which allow styles to be conditional based on various features of elements within the DOM.
Basic selectors
Basic selectors are fundamental selectors; these are the most basic selectors that are frequently combined to create other, more complex selectors.
-
Universal selector
*,ns|*,*|*,|* -
Type selector
elementname -
Class selector
.classname -
ID selector
#idname -
Attribute selector
[attr=value]
Grouping selectors
-
Selector list
A, B -
Specifies that both
AandBelements are selected. This is a grouping method to select several matching elements.
Combinators
Combinators are selectors that establish a relationship between two or more simple selectors, such as "A is a child of B" or "A is adjacent to B."
-
Adjacent sibling combinator
A + B -
Specifies that the elements selected by both
AandBhave the same parent and that the element selected byBimmediately follows the element selected byAhorizontally. -
General sibling combinator
A ~ B -
Specifies that the elements selected by both
AandBshare the same parent and that the element selected byAcomes before—but not necessarily immediately before—the element selected byB. -
Child combinator
A > B -
Specifies that the element selected by
Bis the direct child of the element selected byA. -
Descendant combinator
A B -
Specifies that the element selected by
Bis a descendant of the element selected byA, but is not necessarily a direct child. -
Column combinator
A || B -
Specifies that the element selected by
Bis located within the table column specified byA. Elements which span multiple columns are considered to be a member of all of those columns.
Pseudo
-
Pseudo classes
: -
Specifies a special state of the selected element(s).
-
Pseudo elements
:: -
Represents entities that are not included in HTML.
Concepts
Syntax and semantics
- CSS syntax
- At-rules
- Cascade
- Comments
- Descriptor
- Inheritance
- Shorthand properties
- Specificity
- Value definition syntax
- CSS unit and value types
- CSS functional notations
Values
Layout
- Block formatting context
- Box model
- Containing block
- Layout mode
- Margin collapsing
- Replaced elements
- Stacking context
- Visual formatting model
DOM-CSS / CSSOM
Major object types
Document.styleSheetsstyleSheets[i].cssRules-
cssRules[i].cssText(selector & style) cssRules[i].selectorTextHTMLElement.style-
HTMLElement.style.cssText(just style) Element.classNameElement.classList
Important methods
See also
-
Mozilla CSS extensions (prefixed with
-moz-) -
WebKit CSS extensions (mostly prefixed with
-webkit-) -
Microsoft CSS extensions (prefixed with
-ms-)
External Links
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference