Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.

Follow publication

Understanding the CSS Property

Thiong'o John W
Stackademic
Published in
2 min readAug 21, 2024

The property in CSS is like the wardrobe for your HTML elements—it determines how they dress up and behave on the web page.

The CSS property is a fundamental aspect of web design, controlling how elements are rendered on the page. It determines the layout behavior of an element and its children, making it crucial for creating responsive and visually appealing web pages. In this guide, we’ll explore the most common property values, complete with explanations and visual examples.

1.

Elements with take up the full width available and start on a new line. They are often used for structural elements like , , and .

Example:

<div style="display: block;">This is a block element.</div>

2.

Elements with do not start on a new line and only take up as much width as necessary. They are typically used for text and small elements like , , and .

Example:

<span style="display: inline;">This is an inline element.</span>

3.

Elements with are similar to inline elements but can have width and height set. This makes them useful for creating layouts where elements need to be inline but also have specific dimensions.

Example:

<div style="display: inline-block; width: 100px; height: 50px; background-color: lightblue;">This is an inline-block element.</div>

4.

Elements with are not displayed at all (they are removed from the document flow). This is useful for hiding elements without deleting them from the HTML.

This feature is useful for online quizzes.

Example:

<div style="display: none;">This element is hidden.</div>

5.

Elements with become flexible containers, allowing for more complex layouts. Flexbox is a powerful layout model that provides an efficient way to align and distribute space among items in a container.

Example:

<div style="display: flex;">
<div style="flex: 1;">Flex item 1</div>
<div style="flex: 2;">Flex item 2</div>
</div>

6.

Elements with become grid containers, enabling grid-based layouts. CSS Grid Layout is a two-dimensional layout system that allows for the creation of complex and responsive grid structures.

Example:

<div style="display: grid; grid-template-columns: 1fr 1fr;">
<div>Grid item 1</div>
<div>Grid item 2</div>
</div>

Conclusion

Understanding the CSS property is essential for any web developer. By mastering these common values, you can create more flexible, responsive, and visually appealing web layouts. Experiment with different properties to see how they affect your designs and find the best fit for your projects.

Useful Resources:

  1. display — CSS: Cascading Style Sheets | MDN (mozilla.org)
  2. Create a New Pen (codepen.io)

Stackademic 🎓

Thank you for reading until the end. Before you go:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.

Written by Thiong'o John W

Tech Content Marketer&Strategist. Founder Thion WebWorks. Founder GrowthSpiral. Data Engineer&Analyst.BI. AWS Solutions.Ton Blockchain APIs.Data. AI/ML. Python.

Responses (1)

Write a response

The mininature its made with AI?

--