实用的html代码

Miracle 2017年2月21日19:38:42IT相关 干货教程实用的html代码已关闭评论1,3396243字阅读20分48秒阅读模式

结构性定义文章源自联网快讯-https://x1995.cn/533.html

文件类型<HTML></HTML> (放在档案的开头与结尾)文章源自联网快讯-https://x1995.cn/533.html

文件主题<TITLE></TITLE> (必须放在「文头」区块内)文章源自联网快讯-https://x1995.cn/533.html

文头<HEAD></HEAD> (描述性资料,像是「主题」)文章源自联网快讯-https://x1995.cn/533.html

文体<BODY></BODY> (文件本体)文章源自联网快讯-https://x1995.cn/533.html

标题<H?></H?> (从1到6,有六层选择)文章源自联网快讯-https://x1995.cn/533.html

标题的对齐 <H?ALIGN=LEFT|CENTER|RIGHT></H?>文章源自联网快讯-https://x1995.cn/533.html

区分<DIV></DIV>文章源自联网快讯-https://x1995.cn/533.html

区分的对齐 <DIVALIGN=LEFT|RIGHT|CENTER|JUSTIFY></DIV>文章源自联网快讯-https://x1995.cn/533.html

引文区块<BLOCKQUOTE></BLOCKQUOTE> (通常会内缩)文章源自联网快讯-https://x1995.cn/533.html

强调<EM></EM> (通常会以斜体显示)文章源自联网快讯-https://x1995.cn/533.html

特别强调<STRONG></STRONG> (通常会以加粗显示)文章源自联网快讯-https://x1995.cn/533.html

引文<CITE></CITE> (通常会以斜体显示)文章源自联网快讯-https://x1995.cn/533.html

码<CODE></CODE> (显示原始码之用)文章源自联网快讯-https://x1995.cn/533.html

样本<SAMP></SAMP>文章源自联网快讯-https://x1995.cn/533.html

键盘输入<KBD></KBD>文章源自联网快讯-https://x1995.cn/533.html

变数<VAR></VAR>文章源自联网快讯-https://x1995.cn/533.html

定义<DFN></DFN> (有些浏览器不提供)文章源自联网快讯-https://x1995.cn/533.html

地址 <ADDRESS></ADDRESS>文章源自联网快讯-https://x1995.cn/533.html

大字<BIG></BIG>文章源自联网快讯-https://x1995.cn/533.html

小字<SMALL></SMALL>文章源自联网快讯-https://x1995.cn/533.html

与外观相关的标签(作者自订的表现方式)文章源自联网快讯-https://x1995.cn/533.html

加粗<B></B>文章源自联网快讯-https://x1995.cn/533.html

斜体<I></I>文章源自联网快讯-https://x1995.cn/533.html

底线<U></U> (尚有些浏览器不提供)文章源自联网快讯-https://x1995.cn/533.html

删除线<S></S> (尚有些浏览器不提供)文章源自联网快讯-https://x1995.cn/533.html

下标<SUB></SUB>文章源自联网快讯-https://x1995.cn/533.html

上标<SUP></SUP>文章源自联网快讯-https://x1995.cn/533.html

打字机体<TT></TT> (用单空格字型显示)文章源自联网快讯-https://x1995.cn/533.html

预定格式<PRE></PRE> (保留文件中空格的大小)文章源自联网快讯-https://x1995.cn/533.html

预定格式的宽度<PRE WIDTH=?></PRE>(以字元计算)文章源自联网快讯-https://x1995.cn/533.html

向中看齐<CENTER></CENTER> (文字与图片都可以)文章源自联网快讯-https://x1995.cn/533.html

闪耀<BLINK></BLINK> (有史以来最被嘲弄的标签)文章源自联网快讯-https://x1995.cn/533.html

字体大小 <FONTSIZE=?></FONT>(从1到7)文章源自联网快讯-https://x1995.cn/533.html

改变字体大小 <FONTSIZE=+|-?></FONT>文章源自联网快讯-https://x1995.cn/533.html

基本字体大小 <BASEFONTSIZE=?> (从1到7; 内定为3)文章源自联网快讯-https://x1995.cn/533.html

字体颜色 <FONTCOLOR="#$$"></FONT>($$为颜色代码)文章源自联网快讯-https://x1995.cn/533.html

修改页面文章源自联网快讯-https://x1995.cn/533.html

1)贴图:<img src="图片地址">文章源自联网快讯-https://x1995.cn/533.html

2)加入连接:<a href="所要连接的相关地址">写上你想写的字</a>文章源自联网快讯-https://x1995.cn/533.html

3)在新窗口打开连接:<a href="相关地址" target="_blank">写上要写的字</a>文章源自联网快讯-https://x1995.cn/533.html

4)移动字体(走马灯):<marquee>写上你想写的字</marquee>文章源自联网快讯-https://x1995.cn/533.html

5)字体加粗:<b>写上你想写的字</b>文章源自联网快讯-https://x1995.cn/533.html

6)字体斜体:<i>写上你想写的字</i>文章源自联网快讯-https://x1995.cn/533.html

7)字体下划线: <u>写上你想写的字</u>文章源自联网快讯-https://x1995.cn/533.html

8)字体删除线: <s>写上你想写的字</s>文章源自联网快讯-https://x1995.cn/533.html

9)字体加大: <big>写上你想写的字</big>文章源自联网快讯-https://x1995.cn/533.html

10)字体控制大小:<h1>写上你想写的字</h1> (其中字体大小可从h1-h5,h1最大,h5最小)文章源自联网快讯-https://x1995.cn/533.html

11)更改字体颜色:<font color="#value">写上你想写的字</font>(其中value值在000000与ffffff(16位进制)之间文章源自联网快讯-https://x1995.cn/533.html

12)消除连接的下划线:<a href="相关地址" style="text-decoration:none">写上你想写的字</a>文章源自联网快讯-https://x1995.cn/533.html

13)贴音乐:<embed src="音乐地址" width="宽度" height="高度" autostart=false>文章源自联网快讯-https://x1995.cn/533.html

14)贴flash: <embed src="flash地址" width="宽度" height="高度">文章源自联网快讯-https://x1995.cn/533.html

15)贴影视文件:<img dynsrc="文件地址" width="宽度" height="高度" start=mouseover>文章源自联网快讯-https://x1995.cn/533.html

16)换行:<br>文章源自联网快讯-https://x1995.cn/533.html

17)段落:<p>段落</p>文章源自联网快讯-https://x1995.cn/533.html

18)原始文字样式:<pre>正文</pre>文章源自联网快讯-https://x1995.cn/533.html

19)换帖子背景:<body background="背景图片地址">文章源自联网快讯-https://x1995.cn/533.html

20)固定帖子背景不随滚动条滚动:<body background="背景图片地址" body
bgproperties=fixed>文章源自联网快讯-https://x1995.cn/533.html

21)定制帖子背景颜色:<body bgcolor="#value">(value值见10)文章源自联网快讯-https://x1995.cn/533.html

22)帖子背景音乐:<bgsound="背景音乐地址" loop=infinite>文章源自联网快讯-https://x1995.cn/533.html

23)贴网页:<iframe. src="相关地址" width="宽度" height="高度"></iframe>文章源自联网快讯-https://x1995.cn/533.html

常常会遇到的问题文章源自联网快讯-https://x1995.cn/533.html

点击关闭窗口
<a href="javascript.:top.window.close();">点击关闭窗口</a>!文章源自联网快讯-https://x1995.cn/533.html

请问如何去掉主页右面的滚动条?
<body scroll="no">
<body style="overflow-y:hidden">文章源自联网快讯-https://x1995.cn/533.html

如何做到让一个网页自动关闭.
<html>
<head>
<OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>
</head>
<body >
这个窗口会在10秒过后自动关闭,而且不会出现提示. </body>文章源自联网快讯-https://x1995.cn/533.html

如何在不刷新页面的情况下刷新css?
<style>
button{ color:#000000;}
</style>
<button nclick=document.styleSheets[0].rules[0].style.color=‘‘‘‘red‘‘‘‘>点击按钮直接修改style标签里button选择符使按钮改为  红色</button>
请问如何让网页自动刷新?
在head部记入<META. HTTP-EQUIV="Refresh" c>其中20为20秒后自动刷新,你可以更改为任意值。
如何让页面自动刷新?
方法一,用refresh文章源自联网快讯-https://x1995.cn/533.html

HTML 代码片段如下:
<head>
<meta. http-equiv="refresh" c>
</head>
5表示刷新时间
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]文章源自联网快讯-https://x1995.cn/533.html

方法二,使用setTimeout控制
<img src=/logo.gif>
<script>
function rl(){
document.location.reload()
}
setTimeout(rl,2000)
</SCRIPT>文章源自联网快讯-https://x1995.cn/533.html

如何让超链接没有下划线
在源代码中的<HEAD>…</HEAD>之间输入如下代码:
<style. type="text/css"> <!--
a { text-decoration: none}
--> </style>文章源自联网快讯-https://x1995.cn/533.html

请问如何去掉IE的上下滚动条?
<body style=‘‘‘‘overflow:scroll;overflow-y:hidden‘‘‘‘>
</body>文章源自联网快讯-https://x1995.cn/533.html

怎样才能把RealPlayer文件在网页做一个试听连接?
<embed height=25 src=51js.rm type=audio/x-pn-realaudio-plugin width=50 autostart="false" c>文章源自联网快讯-https://x1995.cn/533.html

如何用html实现浏览器上后退按钮的功能?
<a href="java script.:history.go(-1)">点击后退</a>
或者
<script> history.back() </SCRIPT>文章源自联网快讯-https://x1995.cn/533.html

你不一定知道的技巧文章源自联网快讯-https://x1995.cn/533.html

16. ncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
<table borderncontextmenu=return(false)><td>no</table> 可用于Table
17. <body nselectstart="return false"> 取消选取、防止复制
18.onpaste="return false" 不准粘贴
19.oncopy="return false;" ncut="return false;" 防止复制文章源自联网快讯-https://x1995.cn/533.html

20. <link rel="Shortcut Icon"href="favicon.ico"> IE地址栏前换成自己的图标文章源自联网快讯-https://x1995.cn/533.html

21. <link rel="Bookmark"href="favicon.ico"> 可以在收藏夹中显示出你的图标文章源自联网快讯-https://x1995.cn/533.html

22. <inputstyle="ime-mode:disabled"> 关闭输入法文章源自联网快讯-https://x1995.cn/533.html

23. 永远都会带着框架
<script. language="JavaScript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
// --></script>文章源自联网快讯-https://x1995.cn/533.html

24. 防止被人frame.文章源自联网快讯-https://x1995.cn/533.html

<SCRIPT. LANGUAGE=JAVASCRIPT><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>文章源自联网快讯-https://x1995.cn/533.html

25. 网页将不能被另存为文章源自联网快讯-https://x1995.cn/533.html

<noscript><iframe.src=*.html></iframe></noscript>文章源自联网快讯-https://x1995.cn/533.html

26. 查看网页源代码文章源自联网快讯-https://x1995.cn/533.html

<input type=button value=查看网页源代码
onclick="window.location = "view-source:"+"https://x1995.cn"">文章源自联网快讯-https://x1995.cn/533.html

27.删除时确认文章源自联网快讯-https://x1995.cn/533.html

<a href="javascript:if(confirm("确实要删除吗?"))location="boos.asp? &areyou=删除&page=1"">删除</a>文章源自联网快讯-https://x1995.cn/533.html

28.屏蔽功能键Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift键!");//可以换成ALT CTRL
}
document.onkeydown=look;
</script>文章源自联网快讯-https://x1995.cn/533.html

29. 网页不会被缓存
<META. HTTP-EQUIV="pragma" CONTENT="no-cache">
<META. HTTP-EQUIV="Cache-Control"CONTENT="no-cache, must-revalidate">
<META. HTTP-EQUIV="expires"CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META. HTTP-EQUIV="expires"CONTENT="0">文章源自联网快讯-https://x1995.cn/533.html

30.怎样让表单没有凹凸感?
<input type=text style="border:1 solid #000000">
或 <input type=text style="border-left:none;border-right:none; border -top:none; border-bottom: 1 solid#000000"></textarea>文章源自联网快讯-https://x1995.cn/533.html

31.不要滚动条?
让竖条没有:
<body style="overflow:scroll;overflow-y:hidden">
</body>
让横条没有:
<body style="overflow:scroll;overflow-x:hidden">
</body>
两个都去掉?更简单了
<body scroll="no">
</body>文章源自联网快讯-https://x1995.cn/533.html

32.怎样去掉图片链接点击后,图片周围的虚线?文章源自联网快讯-https://x1995.cn/533.html

<a href="#"nFocus="this.blur()"><img src="logo.jpg"border=0></a>文章源自联网快讯-https://x1995.cn/533.html

33.电子邮件处理提交表单文章源自联网快讯-https://x1995.cn/533.html

<form. name="form1"method="post" action="mailt****@***.com"enctype="text/plain">
<input type=submit>
</form>文章源自联网快讯-https://x1995.cn/533.html

34.在打开的子窗口刷新父窗口的代码里如何写?
window.opener.location.reload()文章源自联网快讯-https://x1995.cn/533.html

35.如何设定打开页面的大小
<body nload="top.resizeTo(300,200);">
打开页面的位置<bodynload="top.moveBy(300,200);">文章源自联网快讯-https://x1995.cn/533.html

36.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
<STYLE>
body
{background-image:url(logo.gif); background-repeat:no-repeat;
background-position:center;background-attachment: fixed}
</STYLE>文章源自联网快讯-https://x1995.cn/533.html

37. 检查一段字符串是否全由数字组成
<script. language="Javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>文章源自联网快讯-https://x1995.cn/533.html

38. 获得一个窗口的大小
document.body.clientWidth; document.body.clientHeight文章源自联网快讯-https://x1995.cn/533.html

39. 怎么判断是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");
else alert("全是字符");文章源自联网快讯-https://x1995.cn/533.html

40.TEXTAREA自适应文字行数的多少
<textarea rows=1 name=s1 cols=27npropertychange="this.style.posHeight=this.scrollHeight">
</textarea>文章源自联网快讯-https://x1995.cn/533.html

41. 日期减去天数等于第二个日期
<script. language=Javascript>
function cc(dd,dadd)
{
//可以加上错误处理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(a)
alert(a.getFullYear() + "年" + (a.getMonth() +1) + "月" + a.getDate() + "日")
} cc("12/23/2002",2)
</script>文章源自联网快讯-https://x1995.cn/533.html

42. 选择了哪一个Radio
<HTML><script. language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio"value="style" checked>Style.
<INPUT name="radio1" type="radio"value="barcode">Barcode
<INPUT type="button" value="check"nclick="checkme()">
</BODY></HTML>文章源自联网快讯-https://x1995.cn/533.html

43.脚本永不出错
<SCRIPT. LANGUAGE="JavaScript">
<!-- Hide function killErrors(){return true;} window.onerror = killErrors;// -->
</SCRIPT>文章源自联网快讯-https://x1995.cn/533.html

44.ENTER键可以让光标移到下一个输入框
<input nkeydown="if(event.keyCode==13)event.keyCode=9">文章源自联网快讯-https://x1995.cn/533.html

转自网站文章源自联网快讯-https://x1995.cn/533.html

继续阅读
Miracle
  • 本文由 发表于 2017年2月21日19:38:42