The backbone of the web.
What that means is that HTML is a way to markup content with additional information. That information can be:
If you want to use a programming language to extract data from the web you'll need to know it.
If you want to create your own web applications or sites you'll need to know it.
To mark up an element in a webpage, you surround it with tags. The tags are surrounded in angle brackets < and >. The closing tag is surrounded by a </ and a >
This is an example of some marked up text.
The basic structure of an HTML document
<html>
<head>
[imports and metadata]
</head>
<body>
[the content of your page]
</body>
</html>
Tables have the following structure:
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1</td><td>Cell 2</td>
</tr>
<tr>
<td>Cell 3</td><td>Cell 4</td>
</tr>
</tbody>
</table>
Header 1 | Header 2 |
---|---|
Cell 1 | Cell 2 |
Cell 3 | Cell 4 |
Lists have the following structure:
<ul>
<li>First item</li>
<li>Second item</li>
</ul>
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
Links—called anchors in HTML—are the first html tag that we're going to use attributes for. Attributes are key-value pairs that occur inside the < >'s.
<a href="http://example.com">Some descriptive text</a>
In this case, the href attribute allows you to specify what the URL the link will connect to is.
Images
<img src="images/wonderful-sloth.gif">
Forms
<input type="text" placeholder="What's your name?">
<input type="checkbox">
<select>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<button type="submit">Push me</button>
Grouping
<p>I am a paragraph.</p>
<div>I am a div.</div>
<section>I am a section.</section>
I am a paragraph.
I am a div.
I am a section.
Notice that tags like <div> don't really do anything to the the presentation.
HTML Commments
<!-- Comment on a single line -->
<!--
Comments on
multiple lines
-->
Nothing here...
Inline vs. Block: Inline Elements
<p>Doge is a slang term for "dog"
that is primarily associated with pictures
of Shiba Inus. <img src="doge.jpg">
Photos may be photoshopped to change the
dog's face or captioned with interior
monologues in Comic Sans font.</p>
Doge is a slang term for "dog" that is primarily associated with pictures of Shiba Inus
Photos may be photoshopped to change the dog's face or captioned with interior monologues in Comic Sans font.
Inline vs. Block: Block Elements
<p>Doge is a slang term for "dog"
that is primarily associated with pictures
of Shiba Inus. <div><img src="doge.jpg"></div>
Photos may be photoshopped to change the
dog's face or captioned with interior
monologues in Comic Sans font.</p>
Doge is a slang term for "dog" that is primarily associated with pictures of Shiba Inus
Block elements take up the full width available on a page, effectively blocking out any other elements from sitting next to either side.
Inline elements only take up as much width as is required to display the contents of the element, thereby allowing other elements to be in-line with it.
Common block tags are <div>, <p>, <h1..6>, <ul>, <li>
Common Inline tags are <a>, <img>, <span>, <em>, <strong>
<!doctype html>
<html lang="en">
<head>
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>Here is a very small and simple document.</p>
<h2>Links I like:</h2>
<ul>
<li><a href="http://google.com/">Google</a></li>
<li><a href="http://amazon.com/">Amazon</a></li>
<li><a href="http://netflix.com">Netflix</a></li>
</ul>
</body>
</html>
Let's look at that page...
Default styling is pretty primitive.
We'll worry about that later.
The DOM is also an interface for manipulating the HTML programatically via JavaScript, which lets us