html基础

103 阅读1分钟

HTML的构成

基础:英文名Hyper Text Markup Language,超文本标记语言,超文本:一般包括图片,视频,音乐等。

HTML标题:

通过<h1> <h6>来定义。<h1>称为一级标题,<h2>为二级标题一直到<h6>

例如:<h1>一级标题</h1>
HTML段落:

通过<p></p>定义

HTML链接:

通过<a></a>定义,有title属性。

HTML图像:

通过<img>来定义,没有结束。

例如:<img str="/gril.jpg" width="200" height="100">

其中width和height皆为属性

HTML属性:

  • HTML 元素可以设置属性
  • 属性可以在元素中添加附加信息
  • 属性一般描述于开始标签
  • 属性总是以名称/值对的形式出现,比如:name="value"。
属性符号描述
id#id他是唯一的
class.class可以同时存在多个
style规定元素的行内样式
title描述了元素的额外信息

例如:<h1 id="index" class="abc">坤坤</h1>

也可在head中添加

<style> 
    #index{ 
        属性(键值对) 
          } 
    .abc{ 
        属性(键值对) 
        } 
</style>

HTML样式:

背景颜色:background-color

例如:<h1 style="background: darkslategrey"></h1>

字体样式:font-family

例如:<h1 style="font-family: PMingLiU">坤坤 </h1>

字体颜色:color

例如:<h1 style="color: red">坤坤</h1>

字体大小:font-size

例如:<h1 style="font-size: 20px">坤坤</h1>

文本对齐:text-align

例如:<h1 style="text-align: center">坤坤</h1>

HTML表格:
由`<table></table>`定义其中`<tr></tr>`表示行`<td></td>`表示列。

表头:<th>

HTML列表:
由`<ol></ol>`和`<ul></ul>`定义ol:有序列表,ul:无序列表。其中列用`<li></li>`表示
HTML区块:由<div></div>表示
HTML表单的输入:<input>定义,换行<br>
<input type="text">
<br>
<input type="password">
单选按钮:type ="radio"

例如:<form> <input type="radio" name="sex" value="male">男 <input type="radio" name="sex" value="female">女 </form>

多选按钮:type ="checkbox"

例如:<form> <input type="checkbox" name="vehicle" value="Bike">我喜欢自行车 <input type="checkbox" name="vehicle" value="Car">我喜欢小汽车 </form>

提交按钮: <input type="submit"> 定义了提交按钮。
点击按钮:<button></button>定义,

例如:立即注册

<button type="submit">立即注册</button>

下拉框:<select>中至少包含一对<option>
例如
<select>
  <option>中国大陆 +86</option>
  <option>中国香港 +852</option>
  <option>中国台湾 +886</option>
  <option>中国澳门 +853</option>
  <option>美国     +1</option>
  <option>俄罗斯   +7</option>
</select>