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 is a prolific author and trainer, and the CEO of WatzThis?. His published books include Writing Computer Code, JavaScript for Kids, Coding with JavaScript For Dummies, Beginning HTML5 and CSS3 For Dummies, Webkit For Dummies, CIW eCommerce Certification Bible, and New Riders’ 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.