From 62e8467e59d7d30d7cbda080f6b5f1d37a17d905 Mon Sep 17 00:00:00 2001
From: mjfernez
All HTML files start with the following (note: the spacing does not matter, it's just spaced for readability):
-<html>
- <body>
+<html>
+ <body>
<!-- stuff you see goes here -->
- </body>
-</html>
+ </body>
+</html>You'll notice two tags here. An "html" tag, and a "body" tag, both of which are closed with "</html>" and "</body>" to signify where the sections end. The HTML document proper is anything between the HTML tags. The body of the document contains the actual content that the user sees. For example:
-<html>
- <body>
- <h1>My Great page</h1>
- <p>My great paragraph</p>
- </body>
-</html><html>
+ <body>
+ <h1>My Great page</h1>
+ <p>My great paragraph</p>
+ </body>
+</html>We've introduced two more tags here, both of which are closed within the body section. The "h1" tag defines a "Heading" which tells the browser to render the text big and bold, like a document title. You can @@ -194,33 +179,33 @@ text in a file called "page.html" and open it in your browser.
We can do a lot more than text of course. Let's walk through some more tags in this example:
-<html>
- <body>
- <h1>My Great page</h1>
- <p>My great paragraph</p>
- <br>
- <h3>Please check out these links, really cool stuff!</h3>
- <center>
- <table>
- <tr>
- <td>FSF!</td>
- <td>
- <a href="https://www.fsf.org/">
- <img src="https://static/media.fsf.org/common/img/logo-new.png" />
- </a></td>
- </tr>
- <tr>
- <td>LOONIX!</td>
- <td>
- <a href="https://www.kernel.org/">
- <img src="https://www.kernel.org/theme/images/logos/tux.png" />
- </a>
- </td>
- </tr>
- </table>
- </center>
- </body>
-</html><html>
+ <body>
+ <h1>My Great page</h1>
+ <p>My great paragraph</p>
+ <br>
+ <h3>Please check out these links, really cool stuff!</h3>
+ <center>
+ <table>
+ <tr>
+ <td>FSF!</td>
+ <td>
+ <a href="https://www.fsf.org/">
+ <img src="https://static/media.fsf.org/common/img/logo-new.png" />
+ </a></td>
+ </tr>
+ <tr>
+ <td>LOONIX!</td>
+ <td>
+ <a href="https://www.kernel.org/">
+ <img src="https://www.kernel.org/theme/images/logos/tux.png" />
+ </a>
+ </td>
+ </tr>
+ </table>
+ </center>
+ </body>
+</html>We added a few things here, but it's the same pattern right? <open></close>.
We started by adding a "center" tag, which does what you think: it @@ -239,24 +224,24 @@ world. On it's own, the "a" tag doesn't do anything special. We need to use the tag with an attribute--an extra word that comes after a--in order to make it work for us. A more basic example might be this:
-<a href="https://example.com">Example</a><a href="https://example.com">Example</a>Which you'll see as:
The "href" attribute doesn't have to point to some other website; it can point to anything. For example, you might want to link to picture your cat (maybe hosted at "/var/www/cat.jpg"). You would do it like this:
-<a href="/cat.jpg">example</a><a href="/cat.jpg">example</a>You can also link an email like this
-<a href="mailto:email@example.com">example email</a><a href="mailto:email@example.com">example email</a>Let's say you had a barebones site with 5 HTML files named: index.html, about.html, faq.html, cats.html, vidya.html. You can make a neat little navbar just using "a" tags like this:
-<a href="/index.html">home</a>
- - <a href="/about.html">about</a>
- - <a href="/faq.html">faq</a>
- - <a href="/cats.html">cats</a>
- - <a href="/vidya.html">vidya</a><a href="/index.html">home</a>
+ - <a href="/about.html">about</a>
+ - <a href="/faq.html">faq</a>
+ - <a href="/cats.html">cats</a>
+ - <a href="/vidya.html">vidya</a>There are many other tags out there, many of which I don't know, and one which I mentioned before, but didn't explain yet: the "img" tag. In @@ -377,21 +362,21 @@ search engines indexing the site that can improve the user experience. The most common thing you'll see in the head section is the site's title, and something called "meta" tags. As usual, it's best to see an example:
-<html>
- <head>
- <title>My Great page</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <meta name="description" content="a really cool page">
- <meta name="keywords" content="HTML, CSS, JavaScript">
- <meta name="author" content="John Doe">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" type="text/css" href="/static/media/main.css">
- </head>
- <body>
- <h1>My Great page</h1>
- <p>My great paragraph</p>
- </body>
-</html><html>
+ <head>
+ <title>My Great page</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <meta name="description" content="a really cool page">
+ <meta name="keywords" content="HTML, CSS, JavaScript">
+ <meta name="author" content="John Doe">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" type="text/css" href="/static/media/main.css">
+ </head>
+ <body>
+ <h1>My Great page</h1>
+ <p>My great paragraph</p>
+ </body>
+</html>Note that the "meta" tag works like the "img" tag did and has no closing tag.
The first tag in the head is the "title" tag. This is the title of @@ -424,12 +409,12 @@ Cascading Style Sheets (CSS).
The "link" tag in the metadata sections can link any external resource. It's commonly used to make a "favicon" for example, which is the icon you see in the tab of an open page.
-<link rel="icon" href="/favicon.ico"><link rel="icon" href="/favicon.ico">In the last example, we instead make a reference to a CSS formatted style sheet. Like HTML, CSS is just a text file written in a specific syntax. CSS allows you to set attributes to all tags in a specific document and create a unifying style for all your pages.
-<link rel="stylesheet" type="text/css" href="/static/media/main.css"><link rel="stylesheet" type="text/css" href="/static/media/main.css">As before, "href" points to the file to be linked. In this example, we place our CSS in a text file called "main.css" in the "static" directory of "/var/www/html".
@@ -437,16 +422,16 @@ directory of "/var/www/html".Before we make CSS files, I want to stress the point that all this stuff is defined in HTML. You can set these attributes directly in any tag we talked about in the last section. For example:
-<p style="color:red">this text is red</p>
-<p style="color:red;background-color:blue">this background is blue</p>
-<p style="color:red;background-color:blue;text-align:center">this text is centered</p>
-<a href="https://www.webtoons.com/en/challenge/sonichu-/sonichu-1/viewer?title_no=676229&episode_no=2"
+<p style="color:red">this text is red</p>
+<p style="color:red;background-color:blue">this background is blue</p>
+<p style="color:red;background-color:blue;text-align:center">this text is centered</p>
+<a href="https://www.webtoons.com/en/challenge/sonichu-/sonichu-1/viewer?title_no=676229&episode_no=2"
target="_blank"
rel="noopener noreferrer"
style="color:yellow;background-color:red;text-align:right"
- >
+ >
And this links to sonichu
-</a>
+</a>this text is red
@@ -550,11 +535,11 @@ section like this: but usually we use a placeholder tag called "div." You can think of "div" like a divider for content of similar style. In the present example, we can use the class we made with a div tag: -<div class="content">
-<h1>My cat</h1>
-<p>He's a cool cat</p>
-<img src="/cat.jpg" />
-</div><div class="content">
+<h1>My cat</h1>
+<p>He's a cool cat</p>
+<img src="/cat.jpg" />
+</div>In early development, reading this site on my phone was a painful experience. Fortunately, in addition to some tricks above like the -- cgit v1.2.3