A method of using CSS for paragraph typesetting in standard Web pages

Source: Internet
Author: User
Tags modify xmlns
css| Standard | Web page

How to use div CSS to format paragraphs in a standard Web page? You'll get a sense of it through this tutorial.

  Margin

div CSS Layout Paragraph use <p> label, for the upper and lower margins of the paragraph (indentation) can use the margin tag to define the style. Margin is defined as the top, bottom, left, and right four directions, and normally we can use one line to describe the style we need.

Example: margin:20px 8px 8px 20px;

This sentence is expressed separately: Margin-top;margin-right;margin-bottom;margin-left.

The order of the four values is: top, right, bottom, and left. It's the clockwise direction starting 12:00.

How the values are consistent and the values are the same, we can optimize them again.

Can be written as: margin:20px 8px;

This sentence is divided into: up and down, around.

For the text alignment within the paragraph, generally use text-align, such as: Text-align:center;

The following are examples of different paragraph layouts:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >< HTML xmlns= "http://www.w3.org/1999/xhtml" ><pead><meta http-equiv= "Content-type" content= "text/html"; Charset=utf-8 "/><title>webjx.com</title><style type=" text/css "><!--div {width:500px; Background: #ccc;} p {border:1px solid red; background: #fff;} #p1 {margin:20px 8px 8px 20px;/*. Right. Under Left */text-align:center;} #p2 {margin:20px 8px;/* up and down. Left/right/text-align:right;} #p3 {margin:20px;/* Four sides are all * * TEXT-ALIGN:LEFT;} --></style></pead><body><div><p id= "P1" >webjx.com-div css layout FAQ </p><p Id= "P2" >webjx.com-div CSS layout FAQ </p><p id= "P3" >webjx.com-div CSS Layout FAQ </p></div></ Body></ptml>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

  Padding

For the space inside the paragraph, we can use padding to achieve. Some of the properties of padding are similar to margin, and they are not repeated here. Let's look at the following example:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >< HTML xmlns= "http://www.w3.org/1999/xhtml" ><pead><meta http-equiv= "Content-type" content= "text/html"; Charset=utf-8 "/><title>webjx.com</title><style type=" text/css "><!--div {width:500px; Background: #ccc;} p {border:1px solid red; background: #fff;} #p1 {margin:20px 8px 8px 20px;/*. Right. Under Left/padding-top:20px;/* distance to the upper 20 pixels/text-align:center;} #p2 {margin:20px 8px;/* up and down. Left/right/padding-bottom:20px;/* distance of the lower 20 pixels/text-align:right;} #p3 {margin:20px;/* Four edges are * * * text-align:left padding:20px 0;/* distance from the lower part of each 20 pixels */}--></style></pead><body ><div><p id= "P1" >webjx.com-div css layout FAQ </p><p id= "P2" >webjx.com-div CSS layout FAQ </p ><p id= "P3" >webjx.com-div CSS layout FAQ </p></div></body></ptml>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]



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.