![CSS Tutorial](/css/images/css-mini-logo.jpg)
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS Data Type - <ident>
The CSS data type <ident> signifies an arbitrary string that is used as an identifier.
Syntax
The data type <custom-ident> has the syntax that is similar to CSS identifiers, such as property names. The only difference is that it is case-sensitive. It can contain one or more characters, where characters can be one of the following:
Any alphabetical character (A to Z, or a to z),
Any decimal digit (0 to 9),
A hyphen (-),
An underscore (_),
An escaped character (preceded by a backslash, \),
A Unicode character in the format of a backslash (\), followed by one to six hexadecimal digits. It represents the Unicode code point.
Note: Since the syntax of <custom-ident> is case-sensitive, the identifiers such as, ID1, id1, Id1 and iD1 are all different identifiers.
/* Valid identifiers */ test1 /* A mix of alphanumeric characters and numbers */ test-sample /* A mix of alphanumeric characters and numbers with a hyphen (-) */ -test1 /* A dash/hyphen followed by alphanumeric characters */ --test1 /* A custom-property like identifier */ _test1 /* An underscore followed by alphanumeric characters */ \11 test /* A Unicode character followed by a sequence of alphanumeric characters */ test\.sample /* A correctly escaped period */ /* Invalid identifiers */ 25rem /* Must not start with a decimal digit */ -25rem /* Must not start with a dash/hyphen followed by a decimal digit */ test.sample /* Only alphanumeric characters, _, and - needn't be escaped */ 'test1' /* No string allowed */ "test1" /* No string allowed */
CSS <ident> - Custom identifier used as a variable
The following example demonstrates the use of <ident> data type to declare a variable and use it in the css styling:
<html> <head> <style> :root { --body-background-color: peachpuff; } div { background-color: var(--body-background-color); width: 300px; height: 300px; border: 3px solid black; } </style> </head> <body> <h1>custom-ident - example</h1> <div></div> </body> </html>
In the example above, a custom property is declared using the data type <custom-ident>, named --body-background-color to set the color for the div element. Here the syntax uses two dashes to start the name followed by alphabetical characters and hyphens.