2 " Language: Cascading Style Sheets
3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
4 " URL: http://www.fleiner.com/vim/syntax/css.vim
5 " Last Change: 2001 Apr 26
7 " For version 5.x: Clear all syntax items
8 " For version 6.x: Quit when a syntax file was already loaded
9 if !exists("main_syntax")
12 elseif exists("b:current_syntax")
15 let main_syntax = 'css'
21 syn keyword cssTagName address applet area a base basefont
22 syn keyword cssTagName big blockquote body br b caption center
23 syn keyword cssTagName cite code dd dfn dir div dl dt em font
24 syn keyword cssTagName form h1 h2 h3 h4 h5 h6 head hr html img
25 syn keyword cssTagName input isindex i kbd link li link map menu
26 syn keyword cssTagName meta ol option param pre p samp
27 syn keyword cssTagName select small span strike strong style sub sup
28 syn keyword cssTagName table td textarea th title tr tt ul u var
30 syn match cssIdentifier "#[a-zA-Z][a-zA-Z0-9-]*"
32 syn match cssLength contained "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\)\="
33 syn keyword cssColor contained aqua black blue fuchsia gray green lime maroon navy olive purple red silver teal yellow
34 syn match cssColor contained "white"
35 syn match cssColor contained "\(#[0-9A-Fa-f]\{3\}\>\|#[0-9A-Fa-f]\{6\}\>\|rgb\s*(\s*\d\+\(\.\d*\)\=%\=\s*,\s*\d\+\(\.\d*\)\=%\=\s*,\s*\d\+\(\.\d*\)\=%\=\s*)\)"
36 syn match cssURL contained "\<url\s*([^)]*)"ms=s+4,me=e-1
38 syn match cssImportant contained "!\s*important\>"
40 syn match cssFontProperties contained "\<font\>\(-\(family\|style\|variant\|weight\|size\)\)\="
41 syn keyword cssFontProperties contained xyz
42 syn keyword cssFontAttr contained cursive fantasy monospace normal italic oblique
43 syn keyword cssFontAttr contained bold bolder lighter medium larger smaller
44 syn match cssFontAttr contained "\<\(sans\>-\)\=\<serif\>"
45 syn match cssFontAttr contained "\<small-caps\>"
46 syn match cssFontAttr contained "\<\(x\{1,2\}-\)\=\(\<small\>\|\<large\>\)\>"
48 syn match cssColorProperties contained "\<color\>"
49 syn match cssColorProperties contained "\<background\>\(-\(color\|image\|repeat\|attachment\|position\)\>\)\="
50 syn keyword cssColorAttr contained transparent none top center bottom left right scroll fixed
51 syn match cssColorAttr contained "\<\(repeat\|repeat-x\|repeat-y\|no-repeat\)\>"
54 syn match cssTextProperties contained "\<\(word-spacing\|letter-spacing\|text-decoration\|vertical-align\|text-transform\|text-align\|text-indent\|line-height\)\>"
55 syn keyword cssTextAttr contained normal none underline overline blink sub super middle
56 syn keyword cssTextAttr contained capitalize uppercase lowercase none left right center justify
57 syn match cssTextAttr contained "\<line-through\>"
58 syn match cssTextAttr contained "\<\(text-\)\=\<\(top\|bottom\)\>"
60 syn match cssBoxProperties contained "\<margin\>\(-\(top\|right\|bottom\|left\)\>\)\="
61 syn match cssBoxProperties contained "\<padding\>\(-\(top\|right\|bottom\|left\)\>\)\="
62 syn match cssBoxProperties contained "\<border\>\(-\(top\|right\|bottom\|left\)\>\)\=\(-width\>\)\="
63 syn match cssBoxProperties contained "\<border-color\>"
64 syn match cssBoxProperties contained "\<border-style\>"
65 syn keyword cssBoxProperties contained width height float clear
66 syn keyword cssBoxAttr contained auto thin medium thick left right none both
67 syn keyword cssBoxAttr contained none dotted dashed solid double groove ridge inset outset
69 syn keyword cssClassificationProperties contained display
70 syn match cssClassificationProperties contained "\<white-space\>"
71 syn match cssClassificationProperties contained "\<list-\(item\|style\(-\(type\|image\|position\)\)\=\)\>"
72 syn keyword cssClassificationAttr contained block inline none normal pre nowrap
73 syn keyword cssClassificationAttr contained disc circle square decimal none
74 syn match cssClassificationAttr contained "\<list-item\>"
75 syn match cssClassificationAttr contained "\<\(lower\|upper\)-\(roman\|alpha\)\>"
77 syn region cssInclude start="@import" start="@include" end=";" contains=cssComment,cssURL
78 syn match cssBraces contained "[{}]"
79 syn match cssError contained "{@<>"
80 syn region cssDefinition transparent matchgroup=cssBraces start='{' end='}' contains=css.*Attr,css.*Properties,cssComment,cssLength,cssColor,cssURL,cssImportant,cssError,cssString
82 syn match cssPseudoClass transparent ":\S*" contains=cssPseudoClassId
83 syn keyword cssPseudoClassId contained link visited active hover
84 syn match cssPseudoClassId contained "\<first-\(line\|letter\)\>"
86 syn region cssComment start="/\*" end="\*/"
87 syn match cssComment "//.*$"
89 syn region cssString start=+"+ skip=+\\\\\|\\"+ end=+"+
90 syn region cssString start=+'+ skip=+\\\\\|\\'+ end=+'+
92 if main_syntax == "css"
96 " Define the default highlighting.
97 " For version 5.7 and earlier: only when not done already
98 " For version 5.8 and later: only when an item doesn't have highlighting yet
99 if version >= 508 || !exists("did_css_syn_inits")
101 let did_css_syn_inits = 1
102 command -nargs=+ HiLink hi link <args>
104 command -nargs=+ HiLink hi def link <args>
107 HiLink cssComment Comment
108 HiLink cssTagName Statement
109 HiLink cssFontProperties StorageClass
110 HiLink cssColorProperties StorageClass
111 HiLink cssTextProperties StorageClass
112 HiLink cssBoxProperties StorageClass
113 HiLink cssClassificationProperties StorageClass
114 HiLink cssFontAttr Type
115 HiLink cssColorAttr Type
116 HiLink cssTextAttr Type
117 HiLink cssBoxAttr Type
118 HiLink cssClassificationAttr Type
119 HiLink cssPseudoClassId PreProc
120 HiLink cssLength Number
121 HiLink cssColor Constant
123 HiLink cssIdentifier Function
124 HiLink cssInclude Include
125 HiLink cssImportant Special
126 HiLink cssBraces Function
127 HiLink cssError Error
128 HiLink cssInclude Include
129 HiLink cssString String
133 let b:current_syntax = "css"
135 if main_syntax == 'css'