Teachnique
      CourseRoadmaps
      Login

      IntroductionSyntaxSelectorsInclusionMeasurement UnitsColorsBackgroundsFontsTextImagesLinksTablesBordersBorder BlockBorder InlineMarginsListsPaddingCursorOutlinesDimensionScrollbarsInline BlockDropdownsVisibilityOverflowClearfixFloatArrowsResizeQuotesOrderPositionHyphensHoverDisplayFocusZoomTranslateHeightHyphenate CharacterWidthOpacityZ-IndexBottomNavbarOverlayFormsAlignIconsImage GalleryCommentsLoadersAttr SelectorsCombinatorsRootBox ModelCountersClipWriting ModeUnicode-bidimin-contentAllInsetIsolationOverscrollJustify ItemsJustify SelfTab SizePointer EventsPlace ContentPlace ItemsPlace SelfMax Block SizeMin Block SizeMix Blend ModeMax Inline SizeMin Inline SizeOffsetAccent ColorUser Select

      GridGrid LayoutFlexboxVisibilityPositioningLayersPseudo ClassesPseudo Elements@ RulesText EffectsPaged MediaPrintingLayoutsValidationsImage SpritesImportantData Types

      TutorialRounded CornerBorder ImagesMulti BackgroundColorGradientsBox ShadowBox Decoration BreakCaret ColorText ShadowText2d transform3d transformTransitionAnimationMulti columnsBox SizingTooltipsButtonsPaginationVariablesMedia QueriesFunctionsMath FunctionsMaskingShapesStyle ImagesSpecificityCustom Properties

      IntroductionViewportGrid ViewMedia QueriesImagesVideosFrameworks

      Questions and AnswersQuick GuideReferencesColor ReferencesWeb browser ReferencesWeb safe fontsUnitsAnimation

      PX to EM converterColor Chooser & Animation

      Useful ResourcesDiscussion

      Feedback

      Submit request if you have any questions.

      Course
      Margins

      CSS Tutorial

      This CSS tutorial is designed for beginners to navigate through the essentials and intricate aspects of CSS styling. Upon finishing this tutorial, participants will possess a comprehensive understanding of CSS, setting a solid foundation for further exploration and mastery. This guide aims to equip you with the skills necessary to transform your visions into visually appealing web designs, laying the groundwork for your journey towards becoming an accomplished web designer.

      Margins

      This chapter discusses about the margins in CSS. Margins are used to create space around an element.
      They define the amount of space between an element's border and adjacent elements.

      Possible Values

      Following values can be passed to each side:
      Value
      Description
      auto
      The margin is calculated automatically by the browser
      length
      The margin is specified in px, pt, cm, etc
      %
      The margin is specified in percentage (%) of the width of the containing element
      inherit
      The margin is inherited from the parent element
      Note: Negative values are allowed to be passed as margin.

      Syntax

      selector {
      margin: top right bottom left;
      }
      You can specify margins for all sides at once (top, right, bottom, left) or set specific values for individual sides.

      CSS Margins - Related Properties

      You can set the margin for each side individually, which is as follows:
      Property
      Description
      margin
      a shorthand property that sets the margin properties in one declaration
      margin-top
      sets the top margin of the element
      margin-right
      sets the right margin of the element
      margin-bottom
      sets the bottom margin of the element
      margin-left
      sets the left margin of the element
      margin-block
      sets logical block start and end margins for an element.
      margin-inline
      sets logical inline start and end margins of an element.