How to Use the CSS Display Property

The dispay property is used to determine if and how an element appears.

The most common values for the display property are:

  • block
  • inline
  • none

Some common uses of the display property are:

  • To show and hide elements based on user interaction: a common example is a drop-down menu. This dynamic change of style is done with JavaScript.
  • To hide elements for certain media: for example, the images might be "turned off" by setting the display property to none in a style sheet for print.
  • Converting an inline element such as a link to a block element by setting its display property to block.

The following example shows how the display property can be used to turn links into block elements:

<meta charset="UTF-8">
<title>CSS Link Buttons</title>
<style type="text/css">
a {
	padding: 6px 4px;
	margin: 4px;
	border-right: 2px solid #999999;
	border-bottom: 2px solid #999999;
	border-top-width: 0px;
	border-left-width: 0px;
	background-color: #eaf1dd;
	font-family:Verdana, Geneva, sans-serif;
<h1>Button Links</h1>
	<a href=""></a>
	<a href="">Webucator</a>
	<a href="">Google</a>
This code renders the following:
display property demo
Author: Chris Minnick

Chris Minnick, the co-founder of WatzThis?, has overseen the development of hundreds of web and mobile projects for customers from small businesses to some of the world’s largest companies. A prolific writer, Chris has authored and co-authored books and articles on a wide range of Internet-related topics including HTML, CSS, mobile apps, e-commerce, e-business, Web design, XML, and application servers. His published books include Adventures in Coding, JavaScript For Kids For Dummies, Writing Computer Code, Coding with JavaScript For Dummies, Beginning HTML5 and CSS3 For Dummies, Webkit For Dummies, CIW E-Commerce Designer Certification Bible, and XHTML.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. Check out our complete course catalog.