Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What common HTML code do programmers have to know?


May 03, 2021 HTML


Table of contents


HTML, or hyper text markup language, is one of the most widely used languages and is the main language that make up a Web page. I n today's HTML5 gorgeous occupation of the entire Internet, if you want to catch the eye of visitors through the web erratic is not possible, program apes need to master some must know the common HTML code, because only familiar with the commonly used HTML code, program apes in the writing of web pages can be smooth and beautiful, with delicate thinking and creative details to impress and retain web visitors.


HTML-CSS code

Text settings

font-size Font size
font-style font format
font-weight Font thick
color Text color

Tip: Be careful to use web security colors.

Hyperlink settings

text-decoration parameter
underline Culture with text
overline To the text
line-through Clearing a deletion for text
blink Text flashes
none Do not show any of the above effects

Background

background-color Set background color
Background picture background-image: url(URL) The URL is the storage path of the background image, NONE is not.
Background picture repeat Background-repeat: parameter
Parameter range
no-repeat Do not repeat tile background pictures
repeat-x Make the picture only in the horizontal direction
repeat-y Make the picture only in the vertical direction If the background image repeat property is not specified, the browser default is the background image to the horizontal and vertical two directions.
Background picture fixation Background-attachment: parameter
Parameter range Fixed: When the web is scrolling, the background image is fixed with respect to the window of the browser. Scroll: When the web is scrolling, the background image is scrolling together relative to the browser window.
Block
Word spacing word-spacing
Alphabet spacing letter-spacing
Text alignment text-align
Value of parameters Left: left alignment
Right: right alignment
Justify: Aligned with respect to the left and right ends
Vertical alignment vertical-align
parameter TOP:
Bottom:
TEXT-top: relative text top alignment
TEXT-BOTTOM: Right relative to the bottom of the text
Baseline: baseline alignment
Middle: Center is aligned
SUB: Show below
SUPER: Displayed above the form
Text indent Text-Indent: Regeneration Distance
Display style display Block: Block-level elements, wrap before and after the object
Inline: Do not change in front of the object
List-item: Putting in the object before and after, adding the project symbol
None: No display



Box

height high
width width
padding Inner margin
margin Outer distance
Float (floating) Block-level elements can be arranged in a row, such as a horizontal menu.
clear Clear floating

Border

style border style None: Borderless
Dotted: Border as a bit
Dashed: Border is long shortline
Solid: Border is a solid line
Double: Border is double line
width border width
colour border color

List

list-style-type List style The list of different browsers may not be the same, may affect the web, so many of the lists in the web page are displayed by the background image

Mouse

cursor Mouse shape parameters Style = "CURSOR: HAND" hand
Style = "CURSOR: Crosshair" cross
Style = "CURSOR: TEXT" text
STYLE = "CURSOR: WAIT" hourglass
Style = "CURSOR: MOVE" Cross Arrow Shaped:
Style = "CURSOR: Help" Question mark
Style = "CURSOR: E-Resize" right arrow
STYLE = "CURSOR: N-Resize" on arrow shaped
Style = "cursor: nw-resize" left up arrow shaped
Style = "Cursor: W-Resize" left arrow
Style = "cursor: s-resize" down the arrow
Style = "cursor: se-resize" right down arrow shaped
Style = "cursor: sw-resize" left left arrow shaped


HTML Common Code: Structural Definitions

file type Place the beginning of the file and end <html></html>
File topic Must be placed in the "Wenhe" block <title></title>
Writing Descriptive information, like "theme" <head></head>
Stylistic File body <body></body>
title From 1 to 6, there are six layers of choice <h?></h?>
Title <h? align=left|center|right></h?>
distinguish <div></div>
Distinguished alignment <div align=left|right|center|justify></div>
Citation block <blockquote></blockquote>
emphasize Usually displayed in a bevel <em></em>
With particular emphasis on Usually displayed with bold <strong></strong>
Quit Usually displayed in a bevel <cite></cite>
code Show the original code <code></code>
sample <samp></samp>
keyboard input <kbd></kbd>
variable <var></var>
definition Some browsers do not provide <dfn></dfn>
address <address></address>
Big word <big></big>
Small word <small></small>
Bold <b></b>
Bevel <I></I>
Bottom line <u></u>
Delete line <s></s>
Subscript <sub></sub>
Laid <sup></sup>
Typhoon <tt></tt>
Predetermined format <pre></pre>
In the middle Text and pictures can <center></center>
shine The most mocked label ever <blink></blink>



HTML common code: Problems that are often encountered

Click to close the window

<a href="javascript.:top.window.close();">点击关闭窗口</a>!

Try it out . . .

How do I remove the scroll bar on the right side of the home page?

<body scroll="no">

<body style="overflow-y:hidden">


Try it out . . .

Join the Flash file in HTML using the element

<object width="300" height="300" data="helloworld.swf" >


Try it out . . .

How do I refresh css without refreshing the page?

<style>

button{color:#000000;}

</style>

<button onclick=document.styleSheets[0].rules[0].style.color='red'>点击按钮直接修改style标签里button选择符使按钮改为  红色</button>


Try it out . . .

How do I make a web page refresh automatically?

Method 1, use refresh

The HTML code snippet is as follows:

<head>

<meta. http-equiv="refresh" content="3">

</head>

3 means refresh time

Method 2, use settimeout control

<img src=/logo.gif>

<script>

function rl(){

document.location.reload()

}

setTimeout(rl,2000)

</SCRIPT>


Try it out . . .

How to make hyperlinks underlined

<style>

a { text-decoration: none}

</style>


Try it out . . .

How do I use html to implement the back button on my browser?

<a href="java script:history.go(-1)">点击后退</a>

Try it out . . .



HTML Common Code: Tips You Don't Necessarily Know

<link rel="Shortcut Icon"href="favicon.icon"> IE地址栏前换成自己的图标

<link rel="Bookmark"href="favicon.icon"> 可以在收藏夹中显示出你的图标

<inputstyle="ime-mode:disabled"> 关闭输入法

<body onContextMenu = "Window.Event.ReturnValue = false" will be thoroughly shielded

OnselectStart = "Return FALSE" Cancel Pickup

OnPaste = "Return False" is not allowed to paste

ONCOPY = "Return False;" Prevent Copy

ONCUT = "Return False;"> Prevent shear


Try it out . . .

Always carry a frame

<script language="JavaScript">

IF (window == TOP) Top.Location.href = "frames.htm"; //frames.htm is the framework page

</script>


Try it out . . .

Prevent people from being framed.

<script>

if (top.location != self.location)top.location=self.location;

</script>


Try it out . . .

Web pages will not be saved

<noscript><iframe src=*.html></iframe></noscript>

Try it out . . .

View the source code for the web page

<input type=button value=查看网页源代码 onclick="window.location = "view-source:"+"http://www.w3cschool.cn"">

Try it out . . .

Confirm when deleted

<a href="" onclick="javascript:return del();">删除</a>

<script>

function del() {

VAR MSG = "Do you really have to delete? \ n \ n Please confirm!";

if (confirm(msg)==true){

return true;

}else{

return false;}}

</script>

Try it out . . .

Web pages are not cached

<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">


Try it out . . .

How do I make a form feel bump-like?

<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>

<body style="overflow:scroll;overflow-y:hidden"> //滚动条竖条消失

<body style="overflow:scroll;overflow-x:hidden"> //滚动条横条消失

<body scroll="no"> //两种滚动条都消失


Try it out . . .

How do I remove a dashed line around a picture after clicking on a picture link?

<a href="#" onFocus="this.blur()">

<img src="logo.jpg"border=0></a>


Try it out . . .

E-mail processes the submission form

<form. name="form1"method="post" action="mailt****@***.com"enctype="text/plain">

<input type=submit>

</form>


Try it out . . .

How do I write in the code that refreshes the parent window in an open child window?

window.opener.location.reload()

How to set the size of the open page

<body onload="top.resizeTo(300,200);">

<body onload="top.moveBy(300,200);">    //打开页面的位置


Try it out . . .

In the page, how to add a background picture that is not full, pull the page when the background picture does not move

body {background-image:url(logo.gif);

background-repeat:no-repeat;

background-position:center;

background-attachment: fixed}


Try it out . . .

Check that a string consists entirely of numbers

<script>

function checkNum(str){return str.match(//D/)==null}

alert(checkNum("1232142141"))

alert(checkNum("123214214a1"))

</script>


Try it out . . .

Get the size of a window

document.body.clientWidth;

document.body.clientHeight;

How to tell if it's a character

IF (/[1x00-/xff]/g.test(s)) ALERT ("With Chinese characters");

Else Alert ("all characters");


The number of TEXTAREA adaptive text lines

<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">

</textarea>


Try it out . . .

The date minus the number of days is equal to the second date

<script. language=Javascript>

function cc(dd,dadd)

{

// Can add an error handling

var a = new Date(dd)

a = a.valueOf()

a = a - dadd * 24 * 60 * 60 * 1000

a = new Date(a)

Alert (A.Getfullyear () + "Year" + (a.getmonth () +1) + "Month" + A.Getdate () + "Day")

} cc("12/23/2002",2)

</script>


Which Radio was chosen

<script>

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>


Try it out . . .

The script never goes wrong

<SCRIPT>

<Hide function killErrors(){return true;} window.onerror = killErrors;>

</SCRIPT>


Try it out . . .

The ENTER key moves the cursor to the next input box

<input onkeydown="if(event.keyCode==13)event.keyCode=9">



HTML special symbol encoding control table

Special symbols Name the entity Heteth coding Special symbols Name the entity Heteth coding Special symbols Name the entity Heteth coding
Alpha &Alpha; &#913; Beta &Beta; &#914; Gamma &Gamma; &#915;
flood &Delta; &#916; Ε &Epsilon; &#917; Ζ &Zeta; &#918;
Η &Eta; &#919; Theta &Theta; &#920; I &Iota; &#921;
K &Kappa; &#922; L &Lambda; &#923; M &Mu; &#924;
N &Nu; &#925; I'm not going &Xi; &#926; The &Omicron; &#927;
P &Pi; &#928; R &Rho; &#929; S &Sigma; &#931;
T &Tau; &#932; Y &Upsilon; &#933; F &Phi; &#934;
X &Chi; &#935; Y &Psi; &#936; Oh &Omega; &#937;
A &alpha; &#945; B &beta; &#946; C &gamma; &#947;
D &delta; &#948; E &epsilon; &#949; G &zeta; &#950;
the &eta; &#951; I &theta; &#952; I &iota; &#953;
Mr. President, i &kappa; &#954; L &lambda; &#955; M &mu; &#956;
ν &nu; &#957; ξ &xi; &#958; ο &omicron; &#959;
π &pi; &#960; ρ &rho; &#961; ς &sigmaf; &#962;
σ &sigma; &#963; τ &tau; &#964; υ &upsilon; &#965;
φ &phi; &#966; χ &chi; &#967; ψ &psi; &#968;
ω &omega; &#969; ϑ &thetasym; &#977; ϒ &upsih; &#978;
ϖ &piv; &#982; &bull; &#8226; &hellip; &#8230;
&prime; &#8242; &Prime; &#8243; &oline; &#8254;
&frasl; &#8260; &weierp; &#8472; &image; &#8465;
&real; &#8476; &trade; &#8482; &alefsym; &#8501;
&larr; &#8592; &uarr; &#8593; &rarr; &#8594;
&darr; &#8595; &harr; &#8596; &crarr; &#8629;
&lArr; &#8656; &uArr; &#8657; &rArr; &#8658;
&dArr; &#8659; &hArr; &#8660; &forall; &#8704;
&part; &#8706; &exist; &#8707; &empty; &#8709;
&nabla; &#8711; &isin; &#8712; &notin; &#8713;
&ni; &#8715; &prod; &#8719; &sum; &#8722;
&minus; &#8722; &lowast; &#8727; &radic; &#8730;
&prop; &#8733; &infin; &#8734; &ang; &#8736;
&and; &#8869; &or; &#8870; &cap; &#8745;
&cup; &#8746; &int; &#8747; &there4; &#8756;
&sim; &#8764; &cong; &#8773; &asymp; &#8773;
&ne; &#8800; &equiv; &#8801; &le; &#8804;
&ge; &#8805; &sub; &#8834; &sup; &#8835;
&nsub; &#8836; &sube; &#8838; &supe; &#8839;
&oplus; &#8853; &otimes; &#8855; &perp; &#8869;
&sdot; &#8901; &lceil; &#8968; &rceil; &#8969;
&lfloor; &#8970; &rfloor; &#8971; &loz; &#9674;
&spades; &#9824; &clubs; &#9827; &hearts; &#9829;
&diams; &#9830; &nbsp; &#160; ¡ &iexcl; &#161;
¢ &cent; &#162; £ &pound; &#163; ¤ &curren; &#164;
¥ &yen; &#165; ¦ &brvbar; &#166; § &sect; &#167;
¨ &uml; &#168; © &copy; &#169; ª &ordf; &#170;
« &laquo; &#171; ¬ &not; &#172; ­ &shy; &#173;
® &reg; &#174; ¯ &macr; &#175; ° &deg; &#176;
± &plusmn; &#177; ² &sup2; &#178; ³ &sup3; &#179;
´ &acute; &#180; µ &micro; &#181 " &quot; &#34;
< &lt; &#60; > &gt; &#62; ' &#39;