Sublime Text 3中CSS类ID语法着色异常及选择器颜色差异咨询
Hey there! Let’s break down why your #about selector isn’t showing up in purple like #logo_text_box_line, and fix that general ID/class coloring problem you’re seeing.
Common Causes & Solutions
1. Double-Check the File’s Syntax Mode
Sublime Text might have misidentified your file as something other than CSS, which kills proper syntax highlighting. Here’s how to fix it:
- Look at the bottom-right corner of your Sublime window—you should see "CSS" listed there. If not, click that text and select "CSS" from the dropdown menu.
- Alternatively, use the command palette: Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac), typeSet Syntax: CSS, and hit Enter.
2. Disable Conflicting Third-Party Plugins
If you’ve installed CSS-focused plugins like CSS3 or Better CSS, they might override Sublime’s default syntax rules and cause inconsistencies. Try this:
- Go to
Preferences > Package Control > Disable Package, then pick any CSS-related plugins you have installed. - Restart Sublime Text and check if
#aboutnow highlights correctly. If it does, either adjust the plugin’s settings or switch to a more compatible option.
3. Reset or Check Your Color Scheme
Custom color schemes can sometimes mess up selector coloring. Let’s verify:
- Head to
Preferences > Color Schemeand select a default option likeMonokaiorSolarized Light. - If
#aboutturns purple now, your custom color scheme has an issue. Open the scheme file (viaPreferences > Color Scheme > Open Current Color Scheme) and look for rules targetingmeta.selector.id.cssorentity.name.tag.css—make sure the color value matches what’s used for#logo_text_box_line.
4. Fix Hidden Syntax Errors in Your CSS
A tiny syntax mistake before line 76 can throw off the entire parser. Check the code between line 64 and 76 for:
- Missing semicolons at the end of property values
- Unclosed curly braces
{} - Unclosed quotes around strings (like in
background-image: url('image.jpg)`)
For example, a mistake like this would break highlighting for everything after it:
#logo_text_box_line { color: #fff; background-color: #333 /* Oops, missing semicolon here! */ } #about { /* This selector won't highlight correctly */ }
Wrap-Up
Start with the simplest fixes (syntax mode, syntax errors) first—those are the most common culprits. If those don’t work, move on to checking plugins and color schemes.
内容的提问来源于stack exchange,提问作者Josri

