Sie sind auf Seite 1von 2

8/4/13

CSS Display and Visibility


Search w3schools.com: Select Language

HOME

HTML

C SS

JAVASC RIPT

JQUERY

XML

ASP.NET

PHP

SQL

MORE...

R EFER ENC ES

EXAMPLES

FO R UM

ABO UT

Get Certified
Study Web Technologies and get a diploma at w3schools.com

SHARE THIS PAGE

Like

76k

CSS Basic
CSS HOME CSS Introduction CSS Syntax CSS Id & Class CSS How To

CSS Display and Visibility


Previous Next Chapter
The display property specifies if/how an element is displayed, and the visibility property specifies if an element should be visible or hidden.
Box 1 Box 2 Box 3

WEB HOSTING
Best Web Hosting eUK Web Hosting UK Reseller Hosting Domain, Hosting & Email

CSS Styling
Styling Backgrounds Styling Text Styling Fonts Styling Links Styling Lists Styling Tables

WEB BUILDING
Download XML Editor FREE Website BUILDER FREE Website C reator

Remove

Hide

Reset All

Best Website Templates

CSS Box Model


CSS Box Model CSS Border CSS Outline CSS Margin CSS Padding

Hiding an Element - display:none or visibility:hidden


Hiding an element can be done by setting the display property to "none" or the visibility property to "hidden". However, notice that these two methods produce different results: visibility:hidden hides an element, but it will still take up the same space as before. The element will be hidden, but still affect the layout.

STATISTICS
Browser Statistics OS Statistics Display Statistics

CSS Advanced
CSS Grouping/Nesting CSS Dimension CSS Display CSS Positioning CSS Floating CSS Align CSS Pseudo-class CSS Pseudo-element CSS Navigation Bar CSS Image Gallery CSS Image Opacity CSS Image Sprites CSS Media Types CSS Attribute Selectors CSS Summary

Example
h 1 . h i d d e n{ v i s i b i l i t y : h i d d e n ; }
Try it yourself display:none hides an element, and it will not take up any space. The element will be hidden, and the page will be displayed as if the element is not there:

Example
h 1 . h i d d e n{ d i s p l a y : n o n e ; }
Try it yourself

CSS Display - Block and Inline Elements


A block element is an element that takes up the full width available, and has a line break before and after it. Examples of block elements: <h1> <p> <div> An inline element only takes up as much width as necessary, and does not force line breaks. Examples of inline elements: <span> <a>

CSS Examples
CSS Examples CSS Quiz CSS Certificate

CSS References
CSS Reference CSS Selectors CSS Reference Aural CSS Web Safe Fonts CSS Units CSS Colors CSS Color Values CSS Color Names CSS Color HEX

Changing How an Element is Displayed


Changing an inline element to a block element, or vice versa, can be useful for making the page look a specific way, and still follow web standards. The following example displays list items as inline elements:

Example
l i{ d i s p l a y : i n l i n e ; }
Try it yourself The following example displays span elements as block elements:

Example
s p a n{ d i s p l a y : b l o c k ; }

w3schools.com/css/css_display_visibility.asp

1/2

8/4/13
Try it yourself

CSS Display and Visibility

Note: Changing the display type of an element changes only how the element is displayed, NOT what kind of element it is. For example: An inline element set to display:block is not allowed to have a block element nested inside of it.

More Examples
How to display an element as an inline element. This example demonstrates how to display an element as an inline element. How to display an element as a block element This example demonstrates how to display an element as a block element. How to make a table element collapse This example demonstrates how to make a table element collapse.

Previous

Next Chapter

Top 10 Tutorials
HTML Tutorial HTML5 Tutorial C SS Tutorial C SS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial

Top 10 References
HTML/HTML5 Reference C SS 1,2,3 Reference C SS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML C olors

Examples
HTML Examples C SS Examples XML Examples JavaScript Examples HTML DOM Examples XML DOM Examples AJAX Examples ASP.NET Examples Razor Examples ASP Examples SVG Examples

Quizzes
HTML Quiz HTML5 Quiz XHTML Quiz C SS Quiz JavaScript Quiz jQuery Quiz XML Quiz ASP Quiz PHP Quiz SQL Quiz

Color Picker

Statistics
Browser Statistics Browser OS Browser Display

RE P O RT E RRO R

HO ME

TO P

P RI N T

FO RU M

A BO U T

A D V E RT I SE WI T H U S

W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2013 by Refsnes Data. All Rights Reserved.

w3schools.com/css/css_display_visibility.asp

2/2

Das könnte Ihnen auch gefallen