HTML/CSS/Text/code
Содержание
Blocked and preserved Code
<source lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title>
<style type="text/css" media="Screen">
- .blocked {
display: block;
}
- .preserved {
white-space: pre;
} </style> </head> <body>
*.blocked { display:block; }
*.preserved { white-space:pre; }
*.code { font-family:monospace; }
</body> </html>
</source>
code Element For Adding Code to Your Web Pages
<source lang="html4strict">
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head>
<title>Representing Code, Keyboard Instructions and Programming Variables</title>
</head> <body>
The <code> Element For Adding Code to Your Web Pages
The following line appears inside a <code> element.
<h1>This is a primary heading</h1>
</body> </html>
</source>
code must be within pre (inline elements can"t contain block-level elements)
<source lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Listing 4-18. Code</title>
</head> <body>
<code> function helloWorld() { var button = document.getElementById("button"); if (button) { button.onclick = function(){ alert("Hello world!"); } } } </code>
</body> </html>
</source>
Displaying blocks of code online
<source lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Displaying blocks of code online</title>
<style type="text/css" media="screen"> body {
font: 62.5%/1.5 Verdana, Arial, Helvetica, sans-serif; padding: 20px;
}
.codeList {
border: 1px solid #aaa;
}
.codeList dt {
background: #dddddd; padding: 7px; font-weight: bold; border-bottom: 2px solid #ccc;
}
.codeList li {
background: #ddd; margin-left: 2.5em;
}
.codeList code {
background: #eaeaea; display: block; border-bottom: 2px solid #ffffff; border-right: 2px solid #ffffff; font : 1.2em "Courier New", Courier, monospace; padding: 2px 10px;
} </style> </head> <body>
- Writing out list styles in full
-
import java
class MainClass{
int i;
public static void main
}
</body> </html>
</source>
Formula input
<source lang="html4strict">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title>
<style type="text/css" media="Screen">
- .nowrap {
white-space: nowrap;
}
- .preserved {
white-space: pre;
} </style> </head> <body>
a = x(y2 + z3) + 1
.
</body>
</html>
</source>