HTML Text

HTML Element

Introduction

HTML 元素指的是从开始标签(start tag)到结束标签(end tag)的所有代码。

This is an element:

<p>shiyanlou</p>

Syntax

Nest

<html>
    <body>
        <p>let's go to shiyanlou</p>
    </body>
</html>

Blank element

Wrap

Attributes

Introduction

例子:

<a href="http://www.shiyanlou.com">shiyanlou</a>

href="http://www.shiyanlou.com",这一部分就叫做 <a> 标签的属性,是对 <a> 标签的补充说明,既指向的网页。这样的标签还有很多,下面我们就来动手做几个练习

align

<h1 align="center">Hello world!</h1>

Color

<body bgcolor="#000000"> <!-- 16 进制数 -->
<body bgcolor="rgb(0,0,0)"> <!-- rgb 数值 -->
<body bgcolor="black"> <!-- 颜色名 -->

文本格式化

Introduction

<Pre>

所谓预格式文本就是指代码叶和网页展示是一样的格式,不用额外添加换行符标签就能换行

<pre>
1st line
2nd line
3rd line
</pre>

Style

<p style="text-align:center;font-family:time;color:blue">
Hello world!
</p>

HTML hypertext

<html>
<body>

    <p>let's have an example</p>

    <p>   
    <a href="http://www.shiyanlou.com">
    shiyanlou
    </a>
    </br>
    <a href="http://www.baidu.com">
    </img src="logo.png"> <!--显示相同 PATH 下的 logo.png 图片-->
    </a>
    </p>


</body>
</html>

Opening methods

Example

<a href="http://www.baidu.com" target="_blank">

Prompt text

<a href="http://www.baidu.com" target="_blank" title="baidu">

Anchor

<p>
<a href="#c1">anchor_1</a>
</p>
<p>
<a name="c1">anchor_1 jumps to here</a>
</p>

HTML Table

Introduction

Example:

<html>
<title >TABLE</title>
<body style="font-size:20px">
     <table border="1">  
     <tr>
    <td>T11</td>
    <td>T12</td>
    </tr>
    <tr>
    <td>T21</td>
    <td>T22</td>
    </tr>
     </table>   
</body>
</html>

Important tags & attributes

HTML Image

Insert an image

<body background="PATH to the image">
<img src="路径加文件名">

align

<img src="PATH" align="top">

resize

width="80" height="80"

map

<html>
<head>
<title>image</title>
</head>
<body>
<p>
<img src="logo.png" usemap="#map"/>
<map name="map">
    <area shape="rect" coords="0, 0, 50, 50" href="http://www.baidu.com" target="_blank">
    <!--只有图片从左上角 (0,0) 坐标到右下角 (50,50) 的区域响应点击-->
</map>
</body>
</html>

HTML List

Ordered List

<ol>
<li>1st element</li>
<li>2nd element</li>
<li>3rd element</li>
</ol>

Unordered List

<ul>
<li>1st element</li>
<li>2nd element</li>
<li>3rd element</li>
</ul>

Defined List

<dl>
<dt>1st</dt> <!--Define the title-->
    <dd>1st element</dd>
<dt>2nd</dt>
    <dd>2nd element</dd>
<dt>3rd</dt>
    <dd>3rd element</dd>
</ul>

HTML Block

Introduction

<div>

Example:

<html>
<head>
<title>Div</title>
</head>
<body>
<div style="color:blue;font-family=arial">
<h3>Inside the div, font color is blue</h3>
<p>Paragraphs are combined</p>
<p>With the same style</p>
</div>
<h3>Outside the div, font color is black</h3>
</body>
</html>

HTML 布局

网页布局可以通过 <table> 元素,或者 <div> 元素实现

利用 <talble> 布局

<table width="100">
    <tr>
        <td colspan="2" style="background-color: royalblue">
            <h1 align="center">Part One</h1>
        </td>
    </tr>

    <tr valign="top">
        <td style="background-color: darkorange;width:300px">
        <h1>Part Two</h1>
        </td>
        
        <td style="background-color: forestgreen;height:500px;width:700px;">
            <h1>Part Three</h1>
        </td>
    </tr>

    <tr>
        <td colspan="2" style="background-color: powderblue;height: 100px">
        <h1>Part Four</h1>
        </td>
    </tr>

</table>

利用 <div> 布局

<head>
  <style>
    div#container{width:200px;height:90px;background-color:black;color:white}
    div#header{background-color:royalblue;height:20px}
    div#sidebar{background-color:darkorange;height:50px;width:50px;float:left}
    div#mainbody{background-color:forestgreen;height:50px;width:150px;float:left}
    div#footer{background-color:darkblue;height:20px;clear:both}
    div#formcontainer{width:200px;height:220px;background-color:grey;color:white}
  </style>
</head>
<body>
<div id="container">
  <div id="header">
    Part One
  </div>
  <div id="sidebar">
    Part Two
  </div>
  <div id="mainbody">
    Part Three
  </div>
  <div id="footer">
    Part Four
  </div>
</div>

渲染结果:

Part Three
### HTML 表单 ```html

Input:</br>

CheckBox:</br> check me </br> check me </br>

RadioBox:</br> male </br> female </br>

</html> ``` 渲染结果:

Input:</br>

CheckBox:</br> check me </br> check me </br>

RadioBox:</br> male </br> female </br>