CSS inline block

Created By: chatGPT

The inline-block display property in CSS allows elements to sit next to each other on the same line, while also respecting width and height settings. This combines features of both inline and block elements. For example, it enables you to create horizontally aligned box layouts without using floats.
 .box {
    display: inline-block;
    width: 150px;
    height: 100px;
    margin: 10px;
    background-color: lightblue;
}
You can apply inline-block to various elements such as
, ,

and more. Just remember, when you set an element as inline-block, it will add spacing around the element due to inline spacing.
<div class="box">Box 1</div>
<div class="box">Box 2</div>
<div class="box">Box 3</div>
To remove the extra space caused by inline elements, you can use comments or set the font size to zero on the parent element. This way, the inline-block elements maintain their spacing without any unwanted gaps.
<style>
    .parent {
        font-size: 0;
    }
    .box {
        display: inline-block;
        font-size: 16px; /* Resetting input size */
        /* other styles */
    }
</style>
<div class="parent">
    <div class="box">Box 1</div>
    <div class="box">Box 2</div>
    <div class="box">Box 3</div>
</div>
A useful application of inline-block is in creating navigation bars. Combining inline-block with hover effects provides a more flexible and visually appealing design.
<style>
    .nav {
        list-style-type: none;
        padding: 0;
    }
    .nav-item {
        display: inline-block;
        padding: 15px;
        background-color: lightgray;
    }
    .nav-item:hover {
        background-color: darkgray;
    }
</style>
<ul class="nav">
    <li class="nav-item">Home</li>
    <li class="nav-item">About</li>
    <li class="nav-item">Contact</li>
</ul>
In conclusion, the inline-block property is a powerful tool for web design, allowing for flexible layouts while retaining control over dimensions and styling. Experimenting with this property can lead to elegant and responsive design solutions.
// Example of inline-block usage in CSS:
.box {
    display: inline-block;
    width: 200px;
    height: 200px;
    margin: 10px;
    border: 1px solid black;
}
Introduction And SetupSelectorsType SelectorClass SelectorId SelectorAttribute SelectorsUniversal SelectorGrouping SelectorsCombinatorsDescendant CombinatorChild CombinatorAdjacent Sibling CombinatorGeneral Sibling CombinatorPseudo ClassesHoverNth ChildNth Of TypeFocusVisitedActiveFirst ChildLast ChildOnly ChildPseudo ElementsBeforeAfterFirst LetterFirst LineBox ModelMarginPaddingBorderWidthHeightBox SizingPositioningStaticRelativeAbsoluteFixedStickyZ IndexDisplayInlineBlockInline BlockFlexGridNoneFloatClearTypographyFont FamilyFont SizeFont WeightFont StyleLine HeightLetter SpacingText AlignText DecorationText TransformVertical AlignOverflowOverflow XOverflow YVisibilityClip PathBackgroundsBackground ColorBackground ImageBackground SizeBackground PositionBackground RepeatBackground AttachmentGradientsBordersBorder WidthBorder ColorBorder StyleBorder RadiusShadowsBox ShadowText ShadowFlexboxFlex DirectionJustify ContentAlign ItemsAlign SelfFlex GrowFlex ShrinkFlex BasisOrderGridGrid Template ColumnsGrid Template RowsGrid GapGrid Auto FlowAlign ContentCss VariablesCustom PropertiesAnimationKeyframesTransitionTransformRotateScaleTranslateSkewMedia QueriesMin WidthMax WidthOrientationAspect RatioUnitsPxEmRemVhVwPercentages