CSS setting the dimensions of a SPAN element

Source: Internet
Author: User

CSS sets the dimensions of the SPAN element:
The dimensions of the span element cannot be set by default, and can only be adapted to the size of the content, meaning that the default condition for setting the width and Height properties for a SPAN element is not valid. This occurs because the span element is an inline element and the inline element cannot be sized, as long as it is set to block-level or inline block-level elements.
The code example is as follows:

<!DOCTYPE HTML>    <HTML>    <Head>    <MetaCharSet= "Utf-8">    <Metaname= "Author"content= "http://www.softwhy.com/" />    <title>Ant Tribe</title>    <styletype= "Text/css">#antzone{width:200px;Height:100px;background:Green;Display:Block;}</style>    </Head>  <Body>  <spanID= "Antzone"></span> </Body>    </HTML>

After the code adds the span element to the Display:block property, you can set it as a block-level element, you can set the size, or use Display:inline-block to set it to inline block-level elements, or you can implement the same functionality.

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=13408

For more information, refer to: http://www.softwhy.com/divcss/

CSS setting the dimensions of a SPAN element

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.