Knowledge.CrowdedGames.Group/Books/CodeSnippets.html
2025-04-19 12:26:23 -07:00

270 lines
8.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<link href="../style.css" rel="stylesheet">
<meta name="description" content="Code snippets are provided for other developers to copy and paste.">
<link rel="icon" type="image/png" href="../Book.png">
<title>Code snippets</title>
</head>
<body>
<button onclick="history.back();">Back Out</button>
<h1>HTML snippets</h1>
<table>
<tr><th><a href="#1">HTML boilerplate.</a></th></tr>
<tr><th><a href="#2">Headers.</a></th></tr>
<tr><th><a href="#3">Text.</a></th></tr>
<tr><th><a href="#4">Italics.</a></th></tr>
<tr><th><a href="#5">Bolded.</a></th></tr>
<tr><th><a href="#6">Strike-through and adding.</a></th></tr>
<tr><th><a href="#7">Subscript and superscript (higher and lower).</a></th></tr>
<tr><th><a href="#8">Acronyms (abbreviation).</a></th></tr>
<tr><th><a href="#9">Programming Look (code).</a></th></tr>
<tr><th><a href="#10">Images.</a></th></tr>
<tr><th><a href="#11">Videos.</a></th></tr>
<tr><th><a href="#12">Audio.</a></th></tr>
<tr><th><a href="#13">HyperLinks and contacts.</a></th></tr>
<tr><th><a href="#14">Advanced use of tags.</a></th></tr>
</table>
<hr/>
<h2 id="1">HTML boilerplate.</h2>
<pre>
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta name=&quot;description&quot; content=&quot;Home of an independent developer. Find programming projects, games, and work experience on this website.&quot;&gt;
&lt;title&gt;Sample title here!&lt;/title&gt;
&lt;!-- .ico is a file type for icons. Used for backwards compatibility, but one can use .gif or .png if they wish. --&gt;
&lt;link rel="icon" type=&quot;image/x-icon&quot; href=&quot;favicon.ico&quot;&gt;
&lt;!-- This links to another file for style stuff, but one can use the STYLE & /STYLE tags instead. --&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;
&lt;!-- Links to JavaScript. If you want JavaScript in HTML, use SCRIPT and /SCRIPT tags at the end of the BODY tag instead. --&gt;
&lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;header&gt;
&lt;h1&gt;Stuff at the top&lt;/h1&gt;
&lt;/header&gt;
&lt;p&gt;Stuff for the page&lt;/p&gt;
&lt;footer&gt;
&lt;p&gt;Stuff at the bottom&lt;/p&gt;
&lt;/footer&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<hr/>
<h2 id="2">Headers.</h2>
<pre>
&lt;!-- Make sure to use headers in decending order. Makes it easy on screen readers and other coders. --&gt;
&lt;h1&gt;Header here&lt;/h1&gt;
&lt;h2&gt;Header here&lt;/h2&gt;
&lt;h3&gt;Header here&lt;/h3&gt;
&lt;h4&gt;Header here&lt;/h4&gt;
&lt;h5&gt;Header here&lt;/h5&gt;
&lt;h6&gt;Header here&lt;/h6&gt;
</pre>
<hr/>
<h2 id="3">Text.</h2>
<pre>
&lt;!-- There are multiple ways to display text. Here are a couple of ways to do it: --&gt;
&lt;!-- p stands for paragraph. It is the most frequently used text tag in HTML. --&gt;
&lt;p&gt;Text here&lt;/p&gt;
&lt;!-- noscript does what it says. If scripts are disabled or unsupported, it lists whatever is in the tags --&gt;
&lt;noscript&gt;Text here&lt;/noscript&gt;
</pre>
<hr/>
<h2 id="4">Italics.</h2>
<pre>
&lt;!-- If your text needs a little <i>slant</i> then we got you covered! These both vertually do the same thing. --&gt;
&lt;i&gt;slanted text here&lt;/i&gt;
&lt;em&gt;slanted text here&lt;/em&gt;
</pre>
<hr/>
<h2 id="5">Bolded.</h2>
<pre>
&lt;!-- To get the <b>bolded</b> look of text, just use these! --&gt;
&lt;strong&gt;Bold text here&lt;/strong&gt;
&lt;b&gt;Bold text here&lt;/b&gt;
&lt;!-- samp is a little different. It is bolded, but it uses a monospaced font instead. It replicates computer output --&gt;
&lt;samp&gt;Bold monospaced text here&lt;/samp&gt;
</pre>
<hr/>
<h2 id="6">Strike-through and adding.</h2>
<pre>
&lt;!-- You want a line to go through text. Hey, that is what this is for! --&gt;
&lt;s&gt;deleted text here&lt;/s&gt;
&lt;del&gt;deleted text here&lt;/del&gt;
&lt;strike&gt;deleted text here&lt;/strike&gt;
&lt;!-- Adding things. Enough said. --&gt;
&lt;ins&gt;added text here&lt;/ins&gt;
</pre>
<hr/>
<h2 id="7">Subscript and superscript (higher and lower).</h2>
<pre>
&lt;!-- Make your words <sup>higher!</sup> --&gt;
&lt;sup&gt;Higher text here&lt;sup&gt;
&lt;!-- Make your words <sub>lower!</sub> --&gt;
&lt;sub&gt;Lower text here&lt;sub&gt;
</pre>
<hr/>
<h2>Smaller and bigger text</h2>
<pre>
&lt;!-- make your text <small>smaller than average</small> --&gt;
&lt;small&gt;Small text&lt;/small&gt;
&lt;!-- Depreciated for some reason, but still: make text <big>bigger!</big> --&gt;
&lt;big&gt;Big text&lt;/big&gt;
</pre>
<hr/>
<h2 id="8">Acronyms (abbreviation).</h2>
<pre>
&lt;!-- In case you don't want to type a very long word every time, you can use this! On hover, displays title attribute. --&gt;
&lt;abbr title=&quot;full acronym&quot;&gt;Text here&lt;/abbr&gt;
&lt;!-- Old acronym format. Used for compatibility. --&gt;
&lt;acronym title=&quot;full acronym&quot;Text here&gt;&lt;/acronym&gt;
</pre>
<hr/>
<h2 id="9">Programming Look (code).</h2>
<pre>
&lt;!-- Make something look like a piece of <code>code</code> (copyable too!) with this handy tag. --&gt;
&lt;code&gt;code text here&lt;/code&gt;
&lt;!-- The pre tags are short for "pre formatted text". It is used for long forms of code (for example, this) --&gt;
&lt;pre&gt;code text here&lt;/pre&gt;
</pre>
<hr/>
<h2 id="10">Images.</h2>
<pre>
&lt;!-- Images are frequently used on websites to make the website look good. There are many ways for a website to use an image. --&gt;
&lt;img src=&quot;link to where the image is located on the website.&quot; alt=&quot;Text that is displayed if the image hasn't loaded yet or failed to load.&quot; /&gt;
&lt;!-- Old image format. Harder to use and can only do SVG, PNG and JPEG. Could be used for compatibility. --&gt;
&lt;image href=&quot;link to where the image is located on the website.&quot; height=&quot;number&quot; width=&quot;number&quot; /&gt;
</pre>
<hr/>
<h2 id="11">Videos.</h2>
<pre>
&lt;!-- Expensive on bandwidth, but is generally better at getting points across. Multiple sources can be put for compatibility. --&gt;
&lt;video controls&gt;
&lt;source src=&quot;reference to media.mp4&quot; type=&quot;video/mp4&quot; /&gt;
&lt;/video&gt;
</pre>
<hr/>
<h2 id="12">Audio.</h2>
<pre>
&lt;!-- Audio is used to (in neocities case) play music as a background or as ambiance. It can also serve as sound effects. --&gt;
&lt;audio controls src=&quot;audio source file&quot;&gt;Text in case tags aren't supported&lt;/audio&gt;
</pre>
<hr/>
<h2 id="13">HyperLinks and contacts.</h2>
<pre>
&lt;!-- Hyperlinks are made to send a user to a different page of a website, to another website, to a specific file on a website, and other things! --&gt;
&lt;a href=&quot;FULL link here&quot;&gt;Name here&lt;/a&gt;
&lt; The internet, back in the day, used E-mail and phone numbers for direct contact more often than text or social media. Here is how to replicate that! --&gt;
&lt;address&gt;
&lt;a href=&quot;mailto:Email@test.com&quot;&gt;Text here&lt;/a&gt;
&lt;a href=&quot;tel:+11231231234&quot;&gt;Text here&lt;/a&gt;
&lt;/address&gt;
</pre>
<hr/>
<h2 id="14">Advanced use of tags.</h2>
<p>I try to make these snippets as simple as possible, but sometimes you need something MORE. Check out these resources.</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML">Mozilla HTML developer resources</a> <br>
<a href="https://www.w3schools.com/tags/">W3schools HTML refernece</a> <br>
<a href="https://www.codecademy.com/resources/docs/html">Codecademy concepts reference</a>
<hr/>
<hr/>
<h1>CSS Snippets.</h1>
<table>
<tr><th><a href="#101">Thing 1</a></th></tr>
<tr><th><a href="#102">Thing 2</a></th></tr>
</table>
<hr/>
<h2 id="101">Thing 1</h2>
<hr/>
<h2 id="102">Thing 2</h2>
<hr/>
<hr/>
<h1>JavaScript Snippets.</h1>
<table>
<tr><th><a href="#201">Clock (doesn't update constantly)</a></th></tr>
<tr><th><a href="#202">Thing 2</a></th></tr>
</table>
<hr/>
<h2 id="201">Clock (doesn't update constantly)</h2>
<pre>
&lt;script&gt;
const CurrentTime = new Date();
document.write(&quot;&lt;br&gt;&quot; + CurrentTime);
&lt;/script&gt;</pre>
<hr/>
<h2 id="202">Thing 2</h2>
</body>
</html>