Post

Comprehensive guide to css attributes

Introduction

CSS (Cascading Style Sheets) is the language used to style HTML elements on a webpage. CSS attributes, also called properties, define how elements are rendered on the screen. From layout control to typography, colors, spacing, and more, CSS attributes give developers the power to create visually appealing and functional designs. This article lists all the major CSS attributes and links to feature articles that provide in-depth details about each.


Total CSS Attributes

There are over 150 CSS attributes commonly used to control the layout and style of a webpage. Below is a comprehensive list of these attributes, categorized by functionality, and each is hyperlinked to a more detailed article explaining its usage, syntax, and examples.


Layout & Positioning

  • display: Defines how an element is displayed (block, inline, etc.).
  • position: Specifies the type of positioning method (static, relative, absolute, fixed, sticky).
  • top: Defines the top position relative to the containing element.
  • right: Defines the right position relative to the containing element.
  • bottom: Defines the bottom position relative to the containing element.
  • left: Defines the left position relative to the containing element.
  • float: Specifies whether an element should float to the left or right.
  • clear: Defines how an element should behave next to floated elements.
  • z-index: Specifies the stack order of an element.
  • overflow: Controls the behavior of content that overflows its container.
  • box-sizing: Determines whether the width and height of an element include padding and borders.

Box Model

  • margin: Sets the space outside an element’s border.
  • padding: Sets the space inside an element’s border.
  • border: Defines the border around an element.
  • width: Specifies the width of an element.
  • height: Specifies the height of an element.
  • max-width: Specifies the maximum width an element can have.
  • max-height: Specifies the maximum height an element can have.
  • min-width: Specifies the minimum width an element can have.
  • min-height: Specifies the minimum height an element can have.

Typography

Colors & Background

Flexbox

  • display: flex: Enables Flexbox layout for an element.
  • flex-direction: Defines the direction of flex items.
  • justify-content: Aligns items along the main axis.
  • align-items: Aligns items along the cross axis.
  • flex-wrap: Controls whether items are forced onto one line or can wrap onto multiple lines.
  • flex-grow: Specifies how much a flex item will grow relative to the rest.
  • flex-shrink: Specifies how much a flex item will shrink relative to the rest.
  • flex-basis: Sets the initial size of a flex item before space distribution.

Grid

Transitions & Animations

Visibility & Display

  • visibility: Controls whether an element is visible or hidden.
  • display: Defines the display behavior of an element (none, block, inline-block).
  • overflow-x: Controls how content overflow is handled horizontally.
  • overflow-y: Controls how content overflow is handled vertically.

Pseudo-Classes & Pseudo-Elements

  • :hover: Styles an element when it is hovered over.
  • :active: Styles an element when it is being activated (e.g., clicked).
  • :focus: Styles an element when it gains focus.
  • ::before: Inserts content before an element.
  • ::after: Inserts content after an element.

Other Common Attributes

  • cursor: Defines the type of cursor to display (e.g., pointer, default).
  • box-shadow: Adds shadow to an element’s box.
  • border-radius: Rounds the corners of an element’s border.
  • outline: Draws a line around an element outside the border.
  • visibility: Toggles the visibility of an element (visible, hidden).

Conclusion

CSS attributes allow developers to fine-tune every aspect of a webpage’s appearance and behavior. With over 150 CSS properties, each with unique capabilities, mastering them is essential for creating modern, responsive, and visually engaging web pages. The list above gives an overview of the most important CSS attributes. For detailed guides on each, follow the hyperlinks provided.

This post is licensed under CC BY 4.0 by the author.