CSS Properties: How to flex-basis property specifies the initial length of a flexible item?
Solution:
HTML Code:
Explanation:
- This HTML document showcases the use of flexbox properties to specify the initial length of flexible items.
- Comments are added to both HTML and CSS to explain each section of the code.
- The CSS <style> block sets up flexbox layout for the container with id "w3r" and its child div elements.
- The container with id "w3r" is given specific width, height, and border properties.
- Each div element inside the container is set to have a flex basis of 40px by default, ensuring they have an initial length of 40px.
- However, the second div element is specifically targeted and given a flex basis of 80px, making it twice as wide as the other div elements.
- This setup demonstrates how the flex-basis property can be used to specify the initial length of flexible items within a flex container.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics