HTML書式のメモ:PREとPタグ

line
_________________________________________________________

PREタグはPタグが使える所ではいいのか?

** 基本的な使い方です。 **

「HTLM書式のメモ」と題し て、paragraphの概念を基本において考えています。ここでは、PタグとPREタグの微 妙な違いを見て行くことにします。


-----------------------------------------------------------------
<P>
<IMG SRC="../icons/w3c_home.gif" ALIGN="LEFT" ALT="">
「HTLM書式のメモ」と題して、paragraphの概念を基本において考えています。
ここでは、PタグとPREタグの微妙な違いを見て行くことにします。

** PをPREにして、文字部分を整形したら、**

pre1

------------------------------------------------------------------------
<PRE>
<IMG SRC="../icons/w3c_home.gif" ALIGN="LEFT" ALT="">
「HTLM書式のメモ」と題して、paragraphの概念を基本において考えています。
ここでは、PタグとPREタグの微妙な違いを見て行くことにします。


</PRE>

** 文字部分だけで、PREを使ったら、**

「HTLM書式のメモ」と題して、paragraphの概念を基本において考えてい
ます。ここでは、PタグとPREタグの微妙な違いを見て行くことにします。


------------------------------------------------------------------------
<IMG SRC="../icons/w3c_home.gif" ALIGN="LEFT" ALT=""><PRE>
「HTLM書式のメモ」と題して、paragraphの概念を基本において考えていま
す。ここでは、PタグとPREタグの微妙な違いを見て行くことにします。


</PRE>

検証して見ると。

Option settings: Level Wilbur Strict

----------------------------------------------------------------------------
Errors

nsgmls:<OSFD>0:26:49:E: document type does not allow element "IMG" here

25. <PRE>
26. <IMG SRC="../icons/w3c_home.gif" ALIGN="LEFT" ALT="">
27. 「HTLM書式のメモ」と題して、paragraphの概念を基本において考えています。
28. ここでは、PタグとPREタグの微妙な違いを見て行くことにします。
29.
30. </PRE>

===================================
Kinder, Gentler Validation Results
====================================
Here are the Kinder, Gentler Validation results for the document at URL:
Jump to: Weblint Results.
----------------------------------------------------------------------------

HTML Validation Results
Below are the results of attempting to parse this document with an SGML
parser.
Version of HTML selected: HTML 3.2.
----------------------------------------------------------------------------
Error at line 29:
   <IMG SRC="../icons/w3c_home.gif" ALIGN="LEFT" ALT="">
                                                    [^] end tag for `PRE' omitted, but its declaration does not permit this (explanation...)
----------------------------------------------------------------------------
Error at line 34:
   </PRE>
        [^] end tag for element `PRE' which is not open (explanation...)
----------------------------------------------------------------------------
Sorry, this document does not validate as HTML 3.2.
   D'oh!
----------------------------------------------------------------------------
Weblint Results
Below are the results of running Weblint on this document:

     Looks good to me!
----------------------------------------------------------------------------
[HTML 2.0 Checked; ]Maintained and validated by Gerald Oskoboiny
(gerald@cs.ualberta.ca)

DTDを見る。

HTML 3.2 Reference Specification
W3C Recommendation 14-Jan-1997
の
SGML Declaration for HTML 3.2
を見ると。

Preformatted Text
<!-- excludes images and changes in font size -->とコメントがあり、

<!ENTITY % pre.exclusion "IMG|BIG|SMALL|SUB|SUP|FONT">
<!ELEMENT PRE - - (%text)* -(%pre.exclusion)>
element     開始タグ  終了タグ  内容
PRE          必須    必須    (%text)* -(%pre.exclusion)

<!ENTITY % font "TT | I | B  | U | STRIKE | BIG | SMALL | SUB | SUP">
<!ENTITY % phrase "EM | STRONG | DFN | CODE | SAMP | KBD | VAR | CITE">
<!ENTITY % special "A | IMG | APPLET | FONT | BASEFONT | BR | SCRIPT | MAP">
<!ENTITY % form "INPUT | SELECT | TEXTAREA">

(%text)とは:
<!ENTITY % text "#PCDATA | %font | %phrase | %special | %form">
です。
-(%pre.exclusion)つまり、内容になれないものは:
<!ENTITY % pre.exclusion "IMG|BIG|SMALL|SUB|SUP|FONT">

<!ATTLIST PRE
        width NUMBER #implied -- is this widely supported? --
        >
属性の説明がきます。
そして、説明が以下のように続きます。
PRE has the same content model as paragraphs, excluding images and elements
that produce changes in font size, e.g. IMG, BIG, SMALL, SUB, SUP and FONT.

A few user agents support the WIDTH attribute. It provides a hint to the
user agent of the required width in characters. The user agent can use this
to select an appropriate font size or to indent the content appropriately.

DTDを直接読むのでなく、Referenceを使う方法も

==============================
Strict HTML 2.0 DTD Reference
=============================
-----
 PRE 
-----
Required Parts 
       <PRE>characters... </PRE> 
All Parts 
       <PRE WIDTH="..." >characters... <A> <HR> <BR> <TT> <B> <I> <EM> <STRONG>
       <CODE> <SAMP> <KBD> <VAR> <CITE> </PRE> 
Allowed In Content Of... 
       <BLOCKQUOTE> <BODY> <DD> <FORM> <LI> 

---
 P 
---
Required Parts 
       <P>characters... 
All Parts 
       <P>characters... <A> <IMG> <BR> <EM> <STRONG> <CODE> <SAMP> <KBD> <VAR>
       <CITE> <TT> <B> <I> </P> 
Allowed In Content Of... 
       <ADDRESS> <BLOCKQUOTE> <BODY> <DD> <FORM> <LI> 

-----
 IMG 
-----
Required Parts 
       <IMG SRC="..." > 
All Parts 
       <IMG SRC="..." ALT="..." ALIGN="..." ISMAP> 
Allowed In Content Of... 
       <A> <ADDRESS> <B> <BLOCKQUOTE> <BODY> <CITE> <CODE> <DD> <DT> <EM>
       <FORM> <H1> <H2> <H3> <H4> <H5> <H6> <I> <KBD> <LI> <P> <SAMP> <STRONG>
       <TT> <VAR> 

==============
W3C Wilbur DTD
==============
Content

   * #PCDATA
   * a
   * applet
   * b
   * basefont
   * big
   * br
   * cite
   * code
   * dfn
   * em
   * font
   * i
   * img
   * input
   * kbd
   * map
   * samp
   * script
   * select
   * small
   * strike
   * strong
   * sub
   * sup
   * textarea
   * tt
   * u
   * var

Exclusions

   * big
   * font
   * img
   * small
   * sub
   * sup

----------------------------------------------------------------------------

ATTRIBUTES
CONTENT DECLARATION

Tag Minimization
     Open Tag: REQUIRED
     Close Tag: REQUIRED

----------------------------------------------------------------------------

Parent Elements

   * blockquote
   * body
   * center
   * dd
   * div
   * form
   * li
   * td
   * th

----------------------------------------------------------------------------

Top Elements
All Elements
Tree

----------------------------------------------------------------------------
PRE:
Attributes
------------------------------------------------------------------
WIDTH
Value(s)
NUMBER
Default Value
#implied
------------------------------------------------------------------
W3C Wilbur DTD

[Topに戻る。]

[ホームページ][HTML書式メモに戻る]

  Congratulations, this document validates as HTML 3.2!


JIS版:http://www.asahi-net.or.jp/‾bd9y-ktu/jirei_f/pre.html

加藤泰孝 bd9y-ktu@asahi-net.or.jp
Last modified 01/04/1997