Tip: How to define the display properties of CSS elements

Source: Internet
Author: User
Tags visibility
One of the key tips for dealing with HTML elements, and nothing special, is to understand how they work. Most pages can be combined with a little bit of tag, and you can style each one you select. Browser default visual style elements vary by font style, bounds, complement white and, and important, display type.

The most basic display types for
are inline inline, block blocks, and none, which can be assigned to the display property by using the values of inline, chunk, and none respectively.


Inline, as expressed in its own semantics, shows the elements that flow along the line. Anchors and accent elements are traditional inline elements.

The
block breaks the elements before and after them. Both the title and the paragraph elements are examples of traditional block elements.


None, well, not showing this element sounds useless, but for usability reasons (see affinity connection), changing the style sheet, or advanced flip effects are good for use.


such as the default original version of this site, by manipulating some traditional inline and block elements to adapt to the design.


H1 {


Display:inline;


Font-size:2em;


}


#header p {


Display:inline;


Font-size:0.9em;


Padding-left:2em;


}


This allows the title and label line of the "htmldog.com" to be side-by, rather than one, to maintain optimal ease of use.


#navigation, #seeAlso, #comments, #standards {


Display:none;


}


The above code is used in print styles to "close" these elements, for example, for a single page navigation is usually not necessary.


Pay attention to

The difference between
Display:none and Visibility:hidden is that Display:none makes the element completely a dead ball, but visibility:


Hidden is not present in the content but retains the flow position of the element. For example, if the second end of paragraph three is set to Display:none, the first paragraph will go directly to the third paragraph, and the paragraph will have an interval if it is set to Visibility:hidden.


Table


Perhaps the best way to understand table-related display attribute values is to care about HTML tables. The table is an initialized display, and you can use TR and TD respectively to simulate Table-row and Table-cell values.

The
display property goes further, providing Table-column, Table-row-group, Table-column-group, Table-header-group, The values of Table-footer-group and Table-caption are self-describing. The obvious advantage of these values is that you can use columns to construct tables instead of biased row.


Finally, the inline-table sets the table before and after the row.


Note
The CSS table is out of control, can seriously damage the affinity of your Web page (ease of use). HTML should be used to communicate content, so if you have tabular data, you should use HTML tables to arrange them. Using a CSS table only allows you to tune the data, which is completely unreadable without CSS. Very bad. Don't leave Michael Jackson's way.


Other display types


List-item is also self-describing, typically displayed as a list, and used on HTML elements except Li. In order to display correctly, use this display type should be nested within the UL or OL element.


Run-in makes an element inline or block visible, depending on the display properties of its parent element. Not working in IE and Mozilla browser-based browsers.


Campact also makes elements inline or block-dependent, depending on the context. It doesn't work very well either.


marker is simply a value that defines the content attribute with the following: Before and: after pseudo elements. The automatic value of the content attribute is already marker, so this is only useful for displaying properties that overwrite the previous content.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.