Div, span, and center elements in CSS

Source: Internet
Author: User

<Div> and <span> are used to specify a style for the content or bind a script. Although most HTML elements can use style attributes to set style information, many HTML elements have their own default styles, which may be mixed or even conflicted with styles defined by style, we don't want to see it. For example, <strong style = "color: Red"> I am strong! </Strong>. Unlike other HTML elements, <div> and <span> have no default display style. You can use them to specify styles.

(1) <div> (Division) is a block-level element that can contain paragraphs, titles, tables, and even chapters, summaries, and remarks. As a block-level element, a line break is inserted at the beginning and end of a paragraph. <Div align = "">... </Div> is used to set the position of the content block. You can use <div> to bind scripts or styles to any part of the document.

(2) Unlike <div>, <span> is an element in a row and does not cause line breaks. It is a logical embedded grouping element. The most common method is to use it to specify a style for several words or even a few characters in a text segment.

(3) Place the content to be centered in the middle of <center> </center>. The <center> and <Div align = "center"> Functions The Same.

Example: Use of <span> elements.

<P> in this sentence <SPAN class = "important"> some of the text is important! </Span> </P>

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.