HTML & CSS learning notes

Source: Internet
Author: User
Tags html notes

1: HTML Introduction

HTML refers to Hyper Text Markup Language. It is not a programming Language, but Markup Language-- Describe web pages by Tag. Here is a simple example:
1 

In this example,

  • Surrounded by Angle brackets
  • It usually appears in pairs, for example,
  • The first tag in a tag pair is the start tag, and the second tag is the end tag (/+ keyword)

Generally, the skeleton of a webpage is as described in the preceding example:

  • The text between
  • The text between
  • The text between <body> and </body> is visible on the page.
Browser is used to read HTML documents and display page content through tags and web pages. Take Chrome as an example. Right-click and select "view page source code" to view the HTML code of your web page. Of course, there are a lot of content, however, the basic skeleton cannot be escaped as described above. 2: Common HTML notes For this content, refer to the http://www.codecademy.com/glossary/html 3: position in CSS
  • Basic Idea of CSS positioning

Position allows you to define the position of an element relative to its normal location, or relative to the parent element, another element, or even the position of the entire browser window.

  • Everything is framed-- The following content is explained by W3:
Div, h1, or p elements are often called block-level elements. This means that these elements are displayed as a block box ". In contrast, elements such as span and strong are called "in-row elements" because their content is displayed in the row, that is, "In-row boxes ". You can use the display attribute to change the type of the generated box. This means that by setting the display attribute to block, the elements in the row (such as <a> elements) can behave like block-level elements. You can also set display to none to make the generated elements have no boxes at all. In this way, the box and all its content are no longer displayed and do not occupy space in the document. However, in one case, block-level elements are created even if no explicit definition is made. This occurs when some text is added to the beginning of a block-level element (such as a div. Even if these texts are not defined as paragraphs, they are treated as paragraphs:
1 <div>2 some text3 <p>Some more text.</p>4 </div>
In this case, this box is called an unsung block box because it is not associated with a specially defined element. The text lines of block-level elements are similar. Suppose there is a paragraph that contains three lines of text. Each line of text forms an unknown box. You cannot apply a style directly to an untitled block or line box because there is no place to apply the style (note that the line box and the line box are two concepts ). However, this helps you understand that everything you see on the screen forms a certain frame.
  • Position attribute: static
Normal stream: the element box is generated normally, and its position is determined by the position of the element in HTML; it is part of the document stream;
  • Position attribute: relative
The element box is offset by a certain distance (relative to the start point ). The element remains in the shape before its position, and its original space remains. For example:
1 #box_relative {2   position: relative;3   left: 30px;4   top: 20px;5 }
As shown in:

  • Position attribute: absolute
The element box set to absolute positioning is completely deleted from the document stream and located relative to its contained block. The contained block may be another element in the document or an initial contained block; the position of an absolutely located element is relative to the nearest located ancestor element. If the element does not have the located ancestor element, its position is relative to the initial contained block. For example:
#box_absolute {  position: absolute;  left: 30px;  top: 20px;}

As shown in:

  • Position attribute: fixed
Similar to absolute, it only corresponds to the location of the entire browser window. 4: Understanding float in CSS
A floating box can be moved to the left or right until its outer edge hits the border of the contained box or another floating box. Because the floating box is not in the normal stream of the document, the block box in the normal stream of the document performs as if the floating box does not exist.

When frame 1 is moved to the right, it is moved out of the Document Stream and to the right until its right edge hits the right edge of the contained box:

Next, when box 1 is floating to the left, it is detached from the document stream and moved to the left until its left edge hits the left edge of the contained box. Because it is no longer in the document stream, it does not occupy space. In fact, it overwrites Box 2 so that box 2 disappears from the view.

If all three boxes are moved to the left, box 1 floats to the left until the contained box is reached, and the other two boxes move to the left until the first floating box is reached.

As shown in, if the box is too narrow to accommodate three floating elements in a horizontal arrangement, the other floating blocks move down until there is enough space. If the height of floating elements is different, they may be "stuck" by other floating elements when moving down ":

 5: understanding of box-module in CSS -- Introduction

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.