- 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 - <number>
CSS <number> data type represents a scalar value, typically used for numerical quantities. It is a generic term for any numerical value and can include integers, decimals, negative numbers, and scientific notation.
CSS <number> - Valid Syntax
Following is the list of valid numbers:
Number | Description |
---|---|
21 | A raw <integer> is also a <number>. |
3.03 | Positive Fraction |
-264.22 | Negative Fraction |
0.0 | Zero |
+0.0 | Zero, with a leading +. |
-0.0 | Zero, with a leading -. |
.55 | Fractional number without a leading zero. |
11e6 | Scientific notation. |
-5.3e-4 | Complicated scientific notation. |
CSS <number> - Invalid Syntax
Following is the list of invalid numbers:
Number | Description |
---|---|
32. | At least one digit must follow a decimal point. |
+-45.2 | There can be only one leading +/-. |
14.5.6 | There can be just one decimal place. |
CSS <number> - Check Valid/Invalid
In the following example, enter the value and check if the entered number is valid or invalid
<html> <head> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; margin: 0; padding: 20px; text-align: center; } h1 { color: #333; } #input { padding: 10px; margin: 20px; font-size: 16px; } #result { font-size: 18px; margin-top: 10px; } .valid { color: green; } .invalid { color: red; } #submitBtn { padding: 10px 20px; font-size: 16px; cursor: pointer; } </style> </head> <body> <h1>Enter the number to check if it is valid or invalid</h1> <label for="input">Enter a number:</label> <input type="text" id="input" placeholder="Enter a number"> <button id="submitBtn" onclick="checkNumberValidity()">Submit</button> <div id="result"></div> <script> function checkNumberValidity() { const inputElement = document.getElementById('input'); const resultElement = document.getElementById('result'); const inputValue = inputElement.value.trim(); // Regular expression for validating numbers const numberRegex = /^([+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?|[+-]?Infinity)$/; if (numberRegex.test(inputValue)) { resultElement.textContent = 'Valid Number'; resultElement.className = 'valid'; } else { resultElement.textContent = 'Invalid Number'; resultElement.className = 'invalid'; } } </script> </body> </html>
CSS <number> - cubic-bezier() Function
The <number> datatype is used in the cubic-bezier() function in the following example to specify control points along a Cubic-Bézier curve.
The x and y coordinates of these control points are determined by the four <number> values, which range from 0 to 1, and they influence the transition effect's acceleration and timing.
<html> <head> <style> .number { transition-property: font-size, color; transition-duration: 1.5s; font-size: 24px; color: blue; margin: 10px; padding: 10px; display: inline-block; transition-timing-function: cubic-bezier(.17, .67, .83, .67); } .number:hover { font-size: 36px; color: red; } </style> </head> <body> <span class="number">Hover over this text!</span> </body> </html>
Advertisements
To Continue Learning Please Login
Login with Google