
In the following example, a span element is changed to a block element. The display property allows us to change the behavior of inline and block elements by using these values: Examples of inline elements are the span, link tag etc. While the inline elements only take the required space and do not start at the new line. For example, paragraphs, div are the block elements.
#ELEMENTS EXAMPLES FULL#
If you have no idea, the block elements take full available space and starts at a new line. You can see, the second row is disappeared while the third row is moved upward to occupy the space of the second row.Īs such, the CSS display property is used to change the behavior of inline and block elements.
#ELEMENTS EXAMPLES CODE#
See the output and code by clicking the links below: Now, the same example as above except I will use the display property to hide the row in the Bootstrap designed table. Note that, if you use the collapse value for any other elements, it will be rendered as hidden value. You can see the second row is not visible however the table structure remains the same. See the figure below and demo online by clicking the link below: It is used to remove a row while table structure does not effect. The difference is just the jQuery part, where I will use the:Īs such, the collapse value also used for table elements. I will use the same example as above, but this time using the CSS visibility property to show and hide the menu. This will make the menu visible again and links will move down. If you click the show menu link after that, the jQuery query code will add the display: initial value. As menu disappears, the links will move up, occupying the space of the menu because CSS display property does not occupy the element space after display: none is used.

By using display: none, the div will be hidden and so the whole menu as well. As you click on the hide menu link, the jQuery code will be used on the click event of that link to add: display: none property to the parent div.Īs such, the parent div contains the menu, which is the combination of ul, li and elements. Two links are given after the menu: hide menu / show menu.

The links act as the menu items.Īpart from other CSS properties, that are many to design this menu, the display property is not used initially, that means the menu will be visible. In this demo, I have used a div element that contains unordered list, list items and hyperlinks. It will behave like a block element if the block value is used in display property.Ī display example to show / hide menu – div, li, and links For example, the span is an inline element. Using the block value makes the opposite.
