学习html
在vs2012里新建了一个html页,和老师视频中的有点差别,基本的格式是一样的,如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
</body>
</html>
说到<form>标签,很重要!如果要和服务器通讯,则需要被<form>标签包住才行,比如最常用的<input>标签,还有<select>,<textarea>等标签。<input>标签是最主要的表单元素,比如
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<input type="text" />
<input type="button" />
<input type="checkbox" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="hidden" />
<input type="submit" />
<input type="file" />
<input type="image" />
</body>
</html>
但是,有一个问题,没有包在<form>...</form>表单中,不能提交到服务器,服务端页也就不能把我们想要的html代码渲染到浏览器客户端了。除了<submit>标签。
学习中,遇到一个很有用的<label>标签,它更好的实现了聚焦功能。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<label for="userName">姓名:</label><input type="text" id="userName"/>
<label for="pwd">密码: </label><input type="password" id="pwd"/>
</body>
</html>