• Open Source Computer Vision Library

Help:HTML

Wikipedia,自由的百科全书

目录

允许的HTML

以下HTML元素目前允许使用:

  • <b>
  • <big>
  • <blockquote>
  • <br>
  • <caption>
  • <center>
  • <cite>
  • <code>
  • <dd>
  • <div>
  • <dl>
  • <dt>
  • <em>
  • <font>
  • <h1>
  • <h2>
  • <h3>
  • <h4>
  • <h5>
  • <h6>
  • <hr>
  • <i>
  • <li>
  • <ol>
  • <p>
  • <pre>
  • <rb>
  • <rp>
  • <rt>
  • <ruby>
  • <s>
  • <small>
  • <strike>
  • <strong>
  • <sub>
  • <sup>
  • <table>
  • <td>
  • <th>
  • <tr>
  • <tt>
  • <u>
  • <ul>
  • <var>
  • <!-- ... -->

对很多HTML元素,维基标记反而更加方便,参见:Help:编辑。不过,HTML允许使用id,这样就变化无穷了。

接下来从OutputPage.php摘录的源代码附加的说明了什么属性是可用的。

	/* private */ function removeHTMLtags( $text )
	{
		wfProfileIn( "OutputPage::removeHTMLtags" );
		$htmlpairs = array( # Tags that must be closed
			"b", "i", "u", "font", "big", "small", "sub", "sup", "h1",
			"h2", "h3", "h4", "h5", "h6", "cite", "code", "em", "s",
			"strike", "strong", "tt", "var", "div", "center",
			"blockquote", "ol", "ul", "dl", "table", "caption", "pre",
			"ruby", "rt" , "rb" , "rp"
		);
		$htmlsingle = array(
			"br", "p", "hr", "li", "dt", "dd"
		);
		$htmlnest = array( # Tags that can be nested--??
			"table", "tr", "td", "th", "div", "blockquote", "ol", "ul",
			"dl", "font", "big", "small", "sub", "sup"
		);
		$tabletags = array( # Can only appear inside table
			"td", "th", "tr"
		);

		$htmlsingle = array_merge( $tabletags, $htmlsingle );
		$htmlelements = array_merge( $htmlsingle, $htmlpairs );

		$htmlattrs = array( # Allowed attributes--no scripting, etc.
			"title", "align", "lang", "dir", "width", "height",
			"bgcolor", "clear", /* BR */ "noshade", /* HR */
			"cite", /* BLOCKQUOTE, Q */ "size", "face", "color",
			/* FONT */ "type", "start", "value", "compact",
			/* For various lists, mostly deprecated but safe */
			"summary", "width", "border", "frame", "rules",
			"cellspacing", "cellpadding", "valign", "char",
			"charoff", "colgroup", "col", "span", "abbr", "axis",
			"headers", "scope", "rowspan", "colspan", /* Tables */
			"id", "class", "name", "style" /* For CSS */
		);

比如元素“a”在维基代码中被禁止使用,因此

<a href="http://meta.wikimedia.org/wiki/Main_Page">Main Page</a>

生成HTML代码

&lt;a href="http://meta.wikimedia.org/wiki/Main_Page"&gt;Main Page&lt;/a&gt;

是文字而不是链接。

Span

<span>,通用内联文字容器,目前可以默认使用。span可以使用id,class,style:

<span style="color:red">style</span>

<span id="randomfooid">id</span>

<span class="importantmessage">class</span>

生成:

style id class

注意到,更多修饰符可被运用。比如,<strong>(可以加上class、id、style)用于显示强调文字。比如,上例更好的表达就是

<em style="color:red;font-style:normal">style</em>
style

这不仅仅吸引用户的注意力,还可以提醒使用非可视化浏览器或有视力障碍的用户。

Font

注意,此元素不推荐使用,而<span>是替代。

对于一些属性,比如颜色,只能这么用:

<font color="red">红</font>字。

生成

字。

Div

例如让文字是“red”类,可以这么运用:

<div class="red">样例</div>
生成
样例
,如果有“red”类则是红的。
.red {color:red}

可使用。

外部链接

Views
Personal tools