where do you find the curly brackets used in css code or is it just appropriate to use the common brackets.

Dani AI

Generated

Quick answer for : CSS rule blocks must use curly braces { }. Parentheses () and square brackets [] serve different purposes in CSS (functions and attribute selectors, respectively). Using the wrong type of bracket will make the rule invalid and likely break following rules.

/* rule block — curly braces required */
h1 {
  color: #c00;
  margin: 0;
}

/* parentheses for functions, square brackets for attribute selectors */
a[href^="http"] { color: blue; }
div { background-image: url("img.png"); transform: rotate(45deg); }

On keyboards: as pointed out, many English (US) layouts put { and } on the same keys as [ and ] and require Shift. is also correct — other national layouts move or hide them, or require AltGr or different combos. Alternatives when a layout makes them hard to type: Windows Alt codes (with a numeric keypad: Alt+123 for {, Alt+125 for }), the OS character map/character viewer, switching temporarily to a US layout, or letting a modern code editor auto-insert matching braces (auto-close, snippets).

Troubleshooting tips: missing or mismatched braces cause cascading CSS failures — syntax highlighting, linting, or an editor that shows brace pairs will reveal the issue quickly. Browser devtools and the W3C CSS validator help locate parse errors. In short: use { } for CSS blocks, rely on editor features if the keyboard layout is awkward, and check for missing braces when rules stop working.

Recommended Answers

All 5 Replies

where do you find the curly brackets used in css code or is it just appropriate to use the common brackets.

Your kidding right? l hope you mean different to me... It's near the enter button, you have gotta hold shift to use em, l am pretty sure that it is curly brackets only, just use curly brackets for usability anyway...

its a function of keyboard layout
not everyone uses EN-us keyboards
the keyboard mapping for other languages, even other subsets of EN, changes the location of keys, and may move non-standard (in the active language character set) characters to 'third' function positions
dlannetts answer may be expanded to, 'this is where it mostly is, but look everywhere'

with your answer almostbob you have confirmed that l am on the right topic here... :)

thanks dlannets- it's kinda silly not to have spotted them but believe me sometimes you can't see things that are right under your nose- hope to post more.

Sorry, rephrase
dlannetts correct answer may be expanded to, 'this is where it mostly is, but look everywhere'

pebkac errors

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.