HTML, html tutorial

Source: Internet
Author: User

HTML, html tutorial

Introduction to HTML

1. Web browsers read HTML documents and display them as webpages. The browser does not display HTML tags, but uses tags to explain the content of the page.

2.

<Body>

<H1> My First Heading

<P> My first paragraph. </p>

</Body>

</Html>

 

# Text description webpage between

# The text between <body> and </body> is visible page content

# Text between

# Text between <p> and </p> is displayed as a paragraph

 

 

 

HTML link

1. HTML links are defined using the <a> tag.

<A href = "http://www.w3school.com.cn"> This is a link </a>

HTML Image

HTML images are defined using the label.

 

 

 

HTML element syntax

The HTML element starts with the start tag.

HTML element ends with end tag

The content of an element is the content between the start tag and the end tag.

Some HTML elements have empty content (empty content)

Empty elements are closed in the start tag (end with the end of the start tag)

Most HTML elements have attributes

 

 

 

Empty HTML Element

HTML content without content is called an empty element. Empty elements are disabled in the start tag.

 

<Br/> is an empty element that does not close the tag (<br/> label definition line feed ).

 

In XHTML, XML, and HTML of future versions, all elements must be disabled.

 

Adding a slash to the start tag, such as <br/>, is the correct method to disable empty elements. HTML, XHTML, and XML both accept this method.

Even if <br> is valid in all browsers, using <br/> is actually a long-term guarantee.

 

 

 

 

 

 

 

HTML Center

<H1 align = "center"> has additional information about alignment.

<Body bgcolor = "yellow"> you have additional information about the background color.

 

 

 

HTML horizontal line

<Hr/> Create a horizontal line for the tag on the HTML page.

The hr element can be used to separate content.

 

 

Always quote the property value

Attribute values should always be enclosed in quotation marks. Double quotation marks are the most commonly used, but it is no problem to use single quotation marks.

In some cases, for example, if the attribute value itself contains double quotation marks, you must use single quotation marks. For example:

Name = 'bill "HelloWorld" Gates'

 

 

 

 

It is a bad habit to insert an empty row with an empty section mark <p> </p>. Replace it with the <br/> label!

If you want to wrap a line (New Line) without generating a new paragraph, use the <br/> label: <p> This is <br/> a para <br/> graph with line breaks </p>

<Br/> the element is an empty HTML element. Because closing a tag does not make any sense, it does not end the tag.

 

 

 

 

 

Pre-formatted text

This example shows how to use the pre label to control empty rows and spaces.

 

<Pre>

This is

Pre-formatted text. >>>>>>>>>>> Pre-formatted text.

It retains spaces. It retains spaces.

And line feed. And line feed.

 

Pre labels are suitable for displaying computer code.

 

 

 

 

 

Address

This example shows how to write an address in an HTML file.

 

<P> address of Donald Duck: </p>

<Address>

Donald Duck <br/>

Case 555 <br/>

Disneyland <br/>

USA <br/>

</Address>

 

<Br/>

 

<P> W3School address: </p>

<Address>

<A href = "mailto: service@w3school.com.cn"> User Service mailbox </a> <br/>

Shanghai winco Investment Co., Ltd. <br/>

Jinqiao development zone No. 789 <br/>

</Address>

Result:

Addresses of Donald Duck:

 

Donald Duck

BOX 1, 555

Disneyland

USA

 

 

 

 

 

User Service mailbox

Shanghai winco Investment Co., Ltd.

No. 789, Jinqiao development zone

 

 

 

 

 

 

Abbreviations and acronyms

<Abbr title = "United Nations"> UN </abbr>

<Acronym title = "World Wide Web"> WWW </acronym>

 

Text direction

<Bdo dir = "rtl">

Here is some Hebrew text

</Bdo>

Here is some Hebrew text

 

Block reference

<Blockquote>

This is a long reference. This is a long reference. This is a long reference. This is a long reference. This is a long reference. This is a long reference. This is a long reference. This is a long reference. This is a long reference. This is a long reference. This is a long reference.

</Blockquote>

When the blockquote element is used, the browser inserts line breaks and margins, while the q element does not have any special rendering.

 

 

 

HTML style instance-background color

The background-color attribute defines the background color for the element:

<Body style = "background-color: yellow">

<H2 style = "background-color: red"> This is a heading

<P style = "background-color: green"> This is a paragraph. </p>

</Body>

The font-family, color, and font-size attributes define the font family, color, and font size of the text in the element respectively:

<H1 style = "font-family: verdana"> A heading

<P style = "font-family: arial; color: red; font-size: 20px;"> A paragraph. </p>

The text-align attribute specifies the horizontal alignment of text in an element:

<H1 style = "text-align: center"> This is a heading

 

 

 

Use images as links

<A href = "../example/html/lastpage.html" tppabs = "http://www.w3school.com.cn/example/html/lastpage.html">

</A>

 

 

 

 

Table Header

The table header is defined using the <th> label.

<Table border = "1">

<Tr>

<Th> Heading </th >>>>>>> note

<Th> Another Heading </th>

</Tr>

<Tr>

<Td> row 1, cell 1 </td>

<Td> row 1, cell 2 </td>

</Tr>

<Tr>

<Td> row 2, cell 1 </td>

<Td> row 2, cell 2 </td>

</Tr>

</Table>

 

 

 

 

 

Empty cells in the table

Table border = "1">

<Tr>

<Td> row 1, cell 1 </td>

<Td> row 1, cell 2 </td>

</Tr>

<Tr>

<Td> row 2, cell 1 </td>

<Td> & nbsp; </td>

</Tr>

</Table>

 

 

 

 

Unordered list:

<H4> an unordered list:

<Ul>

<Li> coffee </li>

<Li> tea </li>

<Li> milk </li>

</Ul>

 

 

Ordered list:

<H4> An ordered list:

<Ol>

<Li> coffee </li>

<Li> tea </li>

<Li> milk </li>

</Ol>

 

 

 

 

Definition list

<Dl>

<Dt> Coffee </dt>

<Dd> Black hot drink </dd>

<Dt> Milk </dt>

<Dd> White cold drink </dd>

</Dl>

 

 

 

Form

A form is an area that contains form elements.

A form element is an element that allows users to enter information in a form (such as text fields, drop-down lists, single quotes, and check boxes.

The form is defined using the form label (<form>.

Input

In most cases, the form tag used is the input tag (<input> ). The input type is defined by the type attribute.

Text Field

Text fields are used when you need to type letters, numbers, and other content in a form.

 

<Form>

First name:

<Input type = "text" name = "firstname"/>

<Br/>

Last name:

<Input type = "text" name = "lastname"/>

</Form>

 

 

 

Radio button

<Form>

<Input type = "radio" name = "sex" value = "male"/> what does Male name and value mean?

<Br/>

<Input type = "radio" name = "sex" value = "female"/> Female

</Form>

Check box

<Form>

<Input type = "checkbox" name = "bike"/>

I have a bike

<Br/>

<Input type = "checkbox" name = "car"/>

I have a car

</Form>

Action and confirmation buttons of the form

<Form name = "input" action = "html_form_action.asp" method = "get"> name, action, and method?

Username:

<Input type = "text" name = "user"/>

<Input type = "submit" value = "Submit"/> what does value mean?

</Form>

 

 

 

 

Instance:

Simple drop-down list

This example shows how to create a simple drop-down list box on the HTML page. The drop-down list is an optional list.

<Form>

<Select name = "cars">

<Option value = "volvo"> Volvo </option>

<Option value = "saab"> Saab </option>

<Option value = "fiat" selected = "selected"> Fiat </option> "" is the first choice.

<Option value = "audi"> Audi </option>

</Select>

</Form>

Text Field

This example shows how to create a text field (multi-line text input control ). Users can write text in text fields. The number of characters that can be written is unlimited.

<P>

This example cannot be edited

Because our editor uses a textarea

For input,

And your browser does not allow

A textarea inside a textarea.

</P>

 

<Textarea rows = "10" cols = "30">

The cat was playing in the garden.

Create button

<Form>

<Input type = "button" value = "Hello world! ">

</Form>

Create box:

<Fieldset>

<Legend> Health Information: </legend>

<Form>

<Label> Height: <input type = "text"/> </label>

<Label> weight: <input type = "text"/> </label>

</Form>

</Fieldset>

 

 

 

 

Form with input box and confirmation button

<Form action = "http://www.w3school.com.cn/example/html/form_action.asp" method = "get">

<P> First name: <input type = "text" name = "fname"/> </p>

<P> Last name: <input type = "text" name = "lname"/> </p>

<Input type = "submit" value = "Submit"/>

</Form>

Form with check boxes

<Form name = "input" action = "http://www.w3school.com.cn/html/html_form_action.asp" method = "get">

I have a bike:

<Input type = "checkbox" name = "vehicle" value = "Bike" checked = "checked"/>

<Br/>

I have a car:

<Input type = "checkbox" name = "vehicle" value = "Car"/>

<Br/>

I have an airplane:

<Input type = "checkbox" name = "vehicle" value = "Airplane"/>

<Br/>

<Input type = "submit" value = "Submit"/>

</Form>

Form with single-choice button

<Form name = "input" action = "http://www.w3school.com.cn/html/html_form_action.asp" method = "get">

Male:

<Input type = "radio" name = "Sex" value = "Male" checked = "checked">

<Br>

Female:

<Input type = "radio" name = "Sex" value = "Female">

<Br>

<Input type = "submit" value = "Submit">

</Form>

 

 

 

 

 

 

 

 

<H4> vertical header:

<Table border = "1">

<Tr>

<Th> name </th>

<Td> Bill Gates </td>

</Tr>

<Tr>

<Th> phone number </th>

<Td> 555 77 854 </td>

</Tr>

<Tr>

<Th> phone number </th>

<Td> 555 77 855 </td>

</Tr>

</Table>

 

Illustration: Bill Gates

Phone 555 77 854

Phone 555 77 855

 

 

Table with titles

This example shows a table with a title.

<Table border = "6">

<Caption> my title </caption>

<H4> cells that span two columns:

<Table border = "1">

<Tr>

<Th> name </th>

<Th colspan = "2"> phone number </th>

</Tr>

<H4> cells that span two rows:

<Tr>

<Th rowspan = "2"> phone number </th>

<Td> 555 77 854 </td>

</Tr>

 

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.