【HTML5】2.语法入门总结(第二部分)

0.思维导图

【HTML5】2.语法入门总结(第二部分)_第1张图片

1.HTML5基本框架

HTML5 是HyperText Markup Language 5 的缩写,是一种标记语言。
第一个程序,基本框架。

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第一个程序title>
head>
<body>
   hello world
body>
html>

【HTML5】2.语法入门总结(第二部分)_第2张图片

2.语法举例(第二部分)

2.1.表格

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表格基本语法title>
head>
<body>
    
    <table align="center"  border="1" cellpadding="2" cellspacing="0" width="200" height="100">
        <tr>
            <th>姓名th>   <th>性别th> <th>年龄th>
        tr>
        <tr><td>刘德华td> <td>td>   <td>56td>tr>
        <tr><td>张学友td> <td>td>   <td>58td>tr>
    table>
body>
html>

合并表格:

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单元格合并title>
head>
<body>
    <p>步骤p>
    <p>1.确定行和列,跨列colspan、跨行rowsapnp>
    <p>2.写代码p>
    <p>3.删除多余单元格p>
    <table width="500" height="249" border="1" cellspacing="0">
        <tr>
            <td>td>
            <td colspan="2">td>
           
        tr>
        <tr>
            <td rowspan="2">td>
            <td>td>
            <td>td>
        tr>
        <tr>
           
            <td>td>
            <td>td>
        tr>
    
    table>
body>
html>

2.2.列表

无序列表

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表title>
head>
<body>
    <h4>你最喜欢吃的食物h4>
    
    <ul>
        
        <li>西瓜li>
        <li>火锅li>
        <li>菠萝li>
    ul>
body>
html>

有序列表

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>有序列表title>
head>
<body>
    <h4>你最喜欢吃的食物h4>
    
    <ol>
        
        <li>西瓜li>
        <li>火锅li>
        <li>菠萝li>
    ol>
body>
html>

自定义列表

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自定义列表title>
head>
<body>
    

    <dl>
        <dt>关注我们dt>
        <dd>新浪微博dd>
        <dd>微信邮箱dd>
        <dd>联系电话dd>
    dl>
body>
html>

2.3.表单域

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单title>
head>
<body>
    
    <from action="demo.php" method="post" name="name1"> 

    from>
body>
html>

2.4.input表单元素

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>input 表单元素title>
head>
<body>
    <form action="xxx.php" method="get">
         
        用户名: <input type="text" name="username" value="请输入用户名" maxlength="6">   <br> 
        
        密码: <input type="password" name="pwd" >  <br> 
        
        
        
        性别: 男 <input type="radio" name="sex" value=""><input type="radio" name="sex" value="" checked="checked"> 外星人   <input type="radio" name="sex" value="人妖">   <br> 
        
        爱好: 吃饭 <input type="checkbox" name="hobby" value="吃饭"> 睡觉 <input type="checkbox" name="hobby">  打豆豆 <input type="checkbox" name="hobby" checked="checked"> 
        <br> 
        
        <input type="submit" value="免费注册">
        
        <input type="reset" value="重新填写">
        
        <input type="button" value="获取短信验证码"> <br>
        
        上传头像:  <input type="file" >
    form>
body>
html>

type属性值:
【HTML5】2.语法入门总结(第二部分)_第3张图片
除type外的其他属性
【HTML5】2.语法入门总结(第二部分)_第4张图片

2.5.label标签

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>labeltitle>
head>
<body>
    
    <label for="username">用户名:label> <input type="text" id="username"  /> <br />
    性别: <input type="radio" name="sex" id="male" value="male" /> <label for="male">label>
        <input type="radio" name="sex" id="female" value="female" /><label for="female">label> 
body>
html>

2.6.下拉选择框

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>12.select下拉选择标签title>
head>
<body>
    喜欢的城市:<select>
        <option value="重庆">重庆option>
        <option selected="selected" value="湖南">湖南option>
        <option value="深圳">深圳option>
    select>
body>
html>

2.7.文本域

DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>13.textarea文本域标签title>
head>
<body>
    今日心得:<textarea name="xinde" id="xinde" cols="30" rows="10">2022年4月17日,天气阴。好好学习,天天向上。textarea>
body>
html>

你可能感兴趣的:(web,html5,web,前端)