|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 | ||
|
chaos
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Administrator
Join Date: Dec 2004
Posts: 8,712
|
HTML Primer
Changelog: Nov 24th, 2007 - Definition Lists and two additional "common mistakes" added. Nov 23rd, 2007 - Document posted. Sometimes it's easy to take for granted the power of the forum text editor. You press Enter; it makes a new line. You click bold; it bolds the current text. If only the real world was so convenient! Behind the scenes, the forum software is converting what you're doing to a language called HTML. No doubt if you're internet literate enough to be helping out with the site you have a basic understanding of what HTML is... but for those stragglers who don't, HTML is the language that specifies how a web page is to be formatted and laid out. This document aims to give you a basic understanding of translating plain text into a format acceptable for display on smogon.com. This is by no means all to say on the subject - in fact, it's a very limited subset. Step one: know what it looks like! Right click on this page, and select "View Source". Notice the plethora of <item></item> looking entities. These entities are called "tags", and are the basis of formatting a document in HTML. Note the similarities to the BBCode used to formatting text on the forums! Aye, formatting text in HTML is no different than formatting text for use on the forums - it involves surrounding text with tags that instruct the browser on how to display it. The term "markup" will be used henceforth to refer to the action of surrounding text with a tag. For example: Markup "text" with dog. - <dog>text</dog> Markup the preceding text with a cat tag. - <cat><dog>text</dog></cat> You may have noticed that sometimes tags look like this: <tag attribute="value"> as opposed to simply <tag>. For the sake of completeness, attributes are like "options" to the tag. Another BBCode analogy - the quote BBcode looks like this: [quote="chaos"]I'm awesome.[/quote]. Note the ="chaos" - it's similar to an attribute that tells the tag that the quoted user is in fact, me. An HTML-like equivalent would look something like <quote user="chaos">I'm awesome.</quote>. Ok, enough with abstract nonsense. It's time to actually see some real world examples. Lets try formatting the following text in HTML. Quote:
Paragraphs should be marked up with p tags. There are 4 items in the example that should be marked up as "paragraphs." Code:
<p>We all know Aeolus meets the qualifications of bag, but does anyone know the history behind this? Well... it started a few years ago. Bag Aeolus found a site called PokeRealm on the internet and teamed up with Pokemon professional "Big Zero." He soon became admin of said site and propelled it into the Pokemon limelight, where it attracted big name players like "Groundon80."</p> <p>Groundon80 and Aeolus were fooling around playing some Pokemon one day when Groundon80 had the brilliant idea of fooling around with each other instead. They touched each other inappropriately, and finally Aeolus got so excited he wanted to try penetration. No condoms were available, so he used a brown paper bag. Bag Aeolus.</p> <p>Here's why Bag Aeolus shouldn't have done this:</p> <p>I hope both parties don't get angry at me using this example for the HTML primer! It's originally from an Inside Scoop thread. I needed some example text, and this fit the bill appropriately!</p> Code:
<p>We all know Aeolus meets the qualifications of bag, but does anyone know the history behind this? Well... it started a few years ago. Bag Aeolus found a site called PokeRealm on the internet and teamed up with Pokemon professional "Big Zero." He soon became admin of said site and propelled it into the Pokemon limelight, where it attracted big name players like "Groundon80." Groundon80 and Aeolus were fooling around playing some Pokemon one day when Groundon80 had the brilliant idea of fooling around with each other instead. They touched each other inappropriately, and finally Aeolus got so excited he wanted to try penetration. No condoms were available, so he used a brown paper bag. Bag Aeolus.</p> Quote:
Step three: know your headers! Headers are used to logically divide sections of a document. In forum posts, they are usually presented as larger and/or bolded text. In HTML, they are marked up with the tags h1, h2, h3, h4, h5, and h6. Large numbered headers are subheaders of smaller numbered headers: <h2> is a subheader of <h1>, <h3> is a subheader of <h2>, etc. Normally in an HTML document you would use <h1> as the first header, but in the SCMS we will be using <h2> as the first header on most occasions (<h1> is automatically added as the title of the page.) In our example we have one header: "The Trilogy of Bag Aeolus". For this example's sake lets say the the SCMS title (and <h1> of this page) is "Aeolus" and "The Trilogy of Bag Aeolus" is merely a subheader. Code:
<h2>The Trilogy of Bag Aeolus</h2> Step four: know your lists! There two types of lists in HTML: the ordered list <ol> and the unordered list <ul>. Ordered lists number each of their elements starting with 1. Unordered lists bullet each item. Items of both lists are marked up using the <li> tag. Lets translate our example into HTML. Usually in forum posts lists are denoted with *s (like our example), sequential numbers (in which an <ol> should be used!), or with real bullets if the poster was engaged enough to actually use them :) Code:
<ul> <li>Condoms protect against HIV.</li> <li>Groundon80 has been with many a man.</li> <li>Big Zero is probably a bit jealous</li> </ul> Code:
* Item 1 * Item 1.1 * Item 2 Code:
* Item 1 ** Item 1.1 * Item 2 Code:
<ul>
<li>Item 1
<ul>
<li>Item 1.1</li>
</ul>
</li>
<li>Item 2</li>
</ul>
Step five: know your links! A hyperlink (or in colloquial usage, "link") is a typically blue, underlined piece of text that when clicked, will take you to a different resource on the internet. Hyperlinks are created with the <a> tag and require the "href" attribute, which indicates which resource to link to. On the forum, links are specified normally in two manners (Assuming we are trying to link to www.smogon.com/dp/pokemon/ with the text "PokeDex"): Code:
PokeDex Code:
PokeDex http://www.smogon.com/dp/pokemon/ Since our example text did not include any explicit links, we will pick some text to link. Since Aeolus and Groundon80 have forum profiles here, lets link to their pages in our example text. Code:
<p><a href="/forums/member.php?u=526">Groundon80</a> and <a href="/forums/member.php?u=1385">Aeolus</a> were fooling around playing some Pokemon one day when Groundon80 had the brilliant idea of fooling around with each other instead. They touched each other inappropriately, and finally Aeolus got so excited he wanted to try penetration. No condoms were available, so he used a brown paper bag. Bag Aeolus.</p> Our final result Code:
<h2>The Trilogy of Bag Aeolus</h2> <p>We all know Aeolus meets the qualifications of bag, but does anyone know the history behind this? Well... it started a few years ago. Bag Aeolus found a site called PokeRealm on the internet and teamed up with Pokemon professional "Big Zero." He soon became admin of said site and propelled it into the Pokemon limelight, where it attracted big name players like "Groundon80."</p> <p><a href="/forums/member.php?u=526">Groundon80</a> and <a href="/forums/member.php?u=1385">Aeolus</a> were fooling around playing some Pokemon one day when Groundon80 had the brilliant idea of fooling around with each other instead. They touched each other inappropriately, and finally Aeolus got so excited he wanted to try penetration. No condoms were available, so he used a brown paper bag. Bag Aeolus.</p> <p>Here's why Bag Aeolus shouldn't have done this:</p> <ul> <li>Condoms protect against HIV.</li> <li>Groundon80 has been with many a man.</li> <li>Big Zero is probably a bit jealous</li> </ul> <p>I hope both parties don't get angry at me using this example for the HTML primer! It's originally from an Inside Scoop thread. I needed some example text, and this fit the bill appropriately!</p> Images To insert an image, we use the <img> tag. It has two essential attributes - "src", which specifies where the image is located, and "alt", which is text to display if the browser doesn't support images. Normally I leave alt as "" because I feel as if there is no suitable text which conveys the meaning (in a non-redundant way) of the image. Regardless, alt must be present, even if its blank. Other useful attributes are "width" and "height". If you know the width and height of the image you are adding (or, alternatively, if you can find out the width and the height... don't be lazy) it should be added to the tag to ease page loading. Ever had a page that, while loading, kept shifting around the location of the text making it hard to read? It's happened to me a bunch of times. That happens when lazy editors don't add width and height attributes to their tags. Note that this is the first tag we have encountered on our journey that doesn't have a closing tag. We don't write <img></img>, but rather close the tag like this: <img />. The / at the end means it's closed; no additional closing tag is necessary. Code:
<img src="/media/big_surgo.jpg" width="50000" height="6" alt="Surgo sure is massive." /> Character entities <, > are reserved in HTML for tags. One may encode these symbols using character entities. A character entity is composed of an ampersand, the name of the entity, and finally a semicolon. To encode <, we would write <. To encode >, we would write >. It's very important to note that & is reserved in HTML as well! To encode a literal &, one writes &. Exercise caution when writing hyperlinks. If a link is in the form of /page?item1=hello&item2=whatever, then the ampersand in that MUST be written as &. For completeness, we would write this example as <a href="/page?item1=hello&item2=whatever">. Reference: < - < > - > " - " (When working inside attributes, you'll need this occasionally.) & - & Handy entities to know: é - é (Handy for those that don't remember the alt code or don't have editors that support Unicode) — (em dash) - — - (en dash) - – Bold, italic, and other friends (introduction to semantic markup) When you use the "B" button on the forums, is it simply for decoration? Can bold formatting be used anywhere one feels like without respect to the nature of the document you are formatting? Hopefully you answered "no" to both of those questions - Bold formatting should only be used when you want to add emphasis to text. When working with HTML, it's important to divorce the concept of emphasis and presentation of said emphasis (bolding, italics, etc). That's the very nature of semantic markup: formatting text based on what you mean instead of what you want it to look like. It's out of the scope of this document to give a full discussion on the advantages of semantic markup, so you'll just have to trust me (or use Google). Reference: (non-exhaustive) strong emphasis - <strong> emphasis - <em> inserted text - <ins> deleted text - <del> text the user should input on a keyboard - <kbd> code (programming languages) - <code> variables - <var> short quoted passages - <q> long quoted passages - <blockquote> acronyms - <acronym> abbreviations - <abbr> ... and for those who hate thinking semantically: bold - <strong> italic - <em> underline - Don't use it. That's reserved for links only. strikethrough - <del> color - Don't use it. different fonts - Don't use it. different sized text - Don't use it. You have headers anyway. Things I should never see in the SCMS (non-exhaustive) If you want to use any of these damned tags talk to me first. <b>, <i>, <u>, <font>, <strike>, <blink>, <marquee> Definition Lists There is one final variant of list that I neglected to mention before. Definition Lists are used to associate terms and their definitions (or information related to them). If we had a long list... like this: Meteor Mash - A very inaccurate move. Swift Swim - Hey guys, this increases speed! Exegutor - Note that it's spelled Exeggutor... we could mark it up using the <dl>, <dt>, and <dd> tags like so: Code:
<dl> <dt>Meteor Mash</dt> <dd>A very inaccurate move</dd> <dt>Swift Swim</dt> <dd>Hey guys, this increases speed!</dd> <dt>Exegutor</dt> <dd>Note that it's spelled Exeggutor...</dd> </dl> Tables Tables are used to format tabular data, i.e. data that fits naturally into the concept of columns and rows. Think spreadsheets. Anyway, to make a table we use the tags <table>, <thead>, <th>, <tbody>, <tr>, and <td>. There is additional JavaScript you must add currently as well to get sorting to work :) Since this would be impossible to explain in abstract, let's contrive a simple example: we have a table with two columns - User, and Pokemon. We want to insert the data (chaos, Ho-oh), (Steelicks, Steelix), and (Jumpman, Octillery). First let's start off by creating the basic structure of the table. Code:
<table class="sortable"> <thead> </thead> <tbody> </tbody> </table> Code:
<table class="sortable">
<thead>
<tr>
<th>User</th>
<th>Pokemon</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Code:
<table class="sortable">
<thead>
<tr>
<th>User</th>
<th>Pokemon</th>
</tr>
</thead>
<tbody>
<tr>
<td>chaos</td>
<td>Ho-oh</td>
</tr>
<tr>
<td>Steelicks</td>
<td>Steelix</td>
</tr>
<tr>
<td>Jumpman</td>
<td>Octillery</td>
</tr>
</tbody>
</table>
Note: Those who already know tables might be accustomed to setting the attributes "cellspacing", "cellpadding", "border", and "valign" on tables. Not here, kid. Note: If you want sorting, talk to me after your document is finished and in the SCMS. Addendum: Common Mistakes All tags should be lowercase Don't write <P>, don't write <TABLE>, put everything in lower case. Same goes for attributes. No exceptions. All tags must be closed People in the past have tried to get away with not closing <p> and <li>. You must close them. Same goes with <img> - be sure to include the / at the end. Code:
<p>A paragraph <p>Another paragraph Tags must be closed in order Stuff like: Code:
<strong>Hello <em>friends</strong></em> Try to avoid <br /> It's not necessary in 99% of cases - use a different way of formatting the document. <li> can't appear in your document randomly <li> exists ONLY in <ul> and <ol>. Likewise, you cant put random stuff in <ul>s, <ol>s, and <dl>s. <ul> and <ol> ONLY contain <li>s, and <dl> ONLY contains <dt>s and <dd>s. Note that arbitrary HTML can appear inside <li>, <dt>, and <dd>. Conclusion Any questions or comments should be posted in this thread and not PMed to me. Hope you enjoyed this - it took me forever and a half to write over Thanksgiving :) Edit: Use this link to check your work: http://validator.w3.org/#validate_by_input
__________________
!gabite fierce: y'd u mute me?? !gabite fierce: eh bro?? !gabite fierce: u scared that i might bash u cuz u r not replying? ~chaos: you can't honestly think that is the reason lol !gabite fierce: tell me the reason oh is it cuz of bolding the writing? !gabite fierce: eh? !gabite fierce: u scared again? Last edited by Caelum; Jun 10th, 2009 at 3:06:06 PM. Reason: yeah |
||
|
|
|
|
|
#2 |
|
np: Michael Jackson - 'Mon in the Mirror (Dream World mix off the "Black or White" album)
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Administrator
Join Date: Dec 2004
Posts: 4,737
Fuqua: Where business cases are read and devils are blue
|
hey thanks very much for this busy chaos
__________________
![]() You haven't trolled till you've trolled in real life. Read A Mullet's Tale for reference if you haven't yet! |
|
|
|
|
|
#3 |
|
np: Biffy Clyro - Shock Shock
![]() ![]()
Join Date: Feb 2006
Posts: 4,679
Malta
|
Thanks for this chaos.
I have a small question. Is there a special character to display the multiplication and division sign (× and ÷) in HTML? My guides use these characters a bit, and they appear strange when converted to HTML.
__________________
http://users.smogon.com/X-Act For all your Pokemon needs (and more!) including: the Defensive EVs applet, the Probabilities of Breeding IVs in Pokemon applet, and the Ratings of Pokemon Base Stats applet (now Version 2.0!). And also the IV to PID applet! |
|
|
|
|
|
#4 |
|
chaos
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Administrator
Join Date: Dec 2004
Posts: 8,712
|
X-Act: they shouldn't display strange in an HTML document that uses Unicode. All of the Smogon beta site, including the SCMS, uses Unicode. Just insert those characters literally.
If you really need those as entities, a quick Google search tells me they are × and ÷
__________________
!gabite fierce: y'd u mute me?? !gabite fierce: eh bro?? !gabite fierce: u scared that i might bash u cuz u r not replying? ~chaos: you can't honestly think that is the reason lol !gabite fierce: tell me the reason oh is it cuz of bolding the writing? !gabite fierce: eh? !gabite fierce: u scared again? |
|
|
|
|
|
#5 |
|
np: Biffy Clyro - Shock Shock
![]() ![]()
Join Date: Feb 2006
Posts: 4,679
Malta
|
Okay, I left them as is. My HTML previewer program must not be currently using Unicode characters then.
__________________
http://users.smogon.com/X-Act For all your Pokemon needs (and more!) including: the Defensive EVs applet, the Probabilities of Breeding IVs in Pokemon applet, and the Ratings of Pokemon Base Stats applet (now Version 2.0!). And also the IV to PID applet! |
|
|
|
|
|
#6 |
|
Bag
![]() ![]() ![]() ![]() ![]() ![]()
Join Date: Sep 2005
Posts: 3,636
St. Louis
|
great. and, unfortunately, eerily accurate.
|
|
|
|
|
|
#7 |
|
Join Date: Jun 2007
Posts: 543
|
How are we supposed to set out pokemon and movesets. I was doing this like this:
Code:
<p> <strong>Abra</strong> @ Choice Specs/Scarf <br /> Synchronise <br /> • Psychic <br /> • Hidden Power [Fighting] <br /> • Energy Ball <br /> • Shadow Ball </p> <p> <strong>EVs:</strong> 236 SAtk / 196 Spd / 76 HP <br /> <strong>Nature:</strong> Modest or Timid </p> |
|
|
|
|
|
#8 |
|
chaos
![]() ![]() ![]() ![]() ![]() ![]() ![]()
Administrator
Join Date: Dec 2004
Posts: 8,712
|
I used to have a special tag the SCMS recognized for this kind of stuff. What do you need to format a moveset for? In all honesty, for something as sensitive to formatting as a moveset, I would wrap the whole thing in <pre> (preformatted text, all line breaks and whitespace are literal) and format it like that.
<pre> Metagross @ Choice Band ~ Meteor Mash ~ Whatever </pre>
__________________
!gabite fierce: y'd u mute me?? !gabite fierce: eh bro?? !gabite fierce: u scared that i might bash u cuz u r not replying? ~chaos: you can't honestly think that is the reason lol !gabite fierce: tell me the reason oh is it cuz of bolding the writing? !gabite fierce: eh? !gabite fierce: u scared again? |
|
|
|
|
|
#9 |
![]() Join Date: Jan 2007
Posts: 999
|
- Writing the author of the page
In most articles, the HTMLizer would be required to add the author's name, and the person who rewrote it as well. Tentative syntax for that is the following: <div class="author">By <a href="/forums/member.php?u=99999">[Author's name here]</a>, rewritten by <a href="/forums/member.php?u=111111">[Rewriter's name here]</a>.</div> In the above, the author's and user's names must be substituted. The numbers in the <a href="..."> section must be replaced by the author's/rewriter's user ID on the forums, which can be determined by placing the cursor over the user's name, which displays a link to the user's profile page in the statusbar. For example, if you hover over chaos' name in a post, you see "http://www.smogon.com/forums/member.php?u=1" in the statusbar. The bolded part (i.e. 1) is his user ID. Please note that this method does not work with links to the users' profile pages on any forums index (such as the C&C main page, etc). - Table of Contents When writing a table of contents, an ordered list (<ol>) is to be used. However, this list is different from the others in the way that it has a class attribute, set to "toc": <ol class="toc"> In order to create tables of contents, each header has to be "bookmarked", so to speak, which means adding an <a> tag with a name and no href, for instance: <h2><a name="introduction">Introduction</a></h2> This <a> tag must be properly closed as well. Once this is done for all headers (and subheaders if the HTMLizer deems it fit), we move on to the actual TOC creation, which is nothing but creating an ordered list on the following pattern: HTML Code:
<ol class="toc"> <li><a href="#introduction">Introduction</a></li> </ol> Bookmark names are unique, so you can't use the same name for two bookmarks. Also, it is highly recommended to use sensible bookmark names. "introduction" or "battling" are sensible names, "section_1" or "1" are not. I hope this is not too cryptic/hard to understand. If there is any question, please feel free to PM me/post it in this thread.
__________________
Code:
* !!!!!!!IF YOU CHANGE TABS TO SPACES, YOU WILL BE KILLED!!!!!!! * !!!!!!!!!!!!!!DOING SO FUCKS THE BUILD PROCESS!!!!!!!!!!!!!!!! |
|
|
|
|
|
#10 |
![]() Join Date: Jan 2007
Posts: 999
|
HTMLizers are requested to note that it's preferable to include a table of contents in each article that has a scope its inclusion. Also, it is mandatory to include an author tag for every page that needs one. Instructions on that can be located in the HTML primer (last post).
Along with that, if HTMLizers with good prose skills could post a small writeup of the article to appear on the articles index page, it would automate the task of the site staff quite a lot. EDIT: Please include a link back to the source material in your thread.
__________________
Code:
* !!!!!!!IF YOU CHANGE TABS TO SPACES, YOU WILL BE KILLED!!!!!!! * !!!!!!!!!!!!!!DOING SO FUCKS THE BUILD PROCESS!!!!!!!!!!!!!!!! Last edited by ryubahamut; Oct 16th, 2009 at 3:17:08 AM. |
|
|
|
![]() |
| Thread Tools | |
|
|