{"id":274,"date":"2022-01-19T00:09:37","date_gmt":"2022-01-19T00:09:37","guid":{"rendered":"http:\/\/miriamposner.com\/classes\/is270s23\/?page_id=274"},"modified":"2022-03-09T20:16:16","modified_gmt":"2022-03-09T20:16:16","slug":"build-a-webpage-from-scratch-with-html","status":"publish","type":"page","link":"http:\/\/miriamposner.com\/classes\/is270s23\/resources\/web-design\/build-a-webpage-from-scratch-with-html\/","title":{"rendered":"Build a webpage from scratch with HTML"},"content":{"rendered":"\n<p><em>You can also <a href=\"https:\/\/share.descript.com\/view\/VP3aq6Aa5Gi\" target=\"_blank\" rel=\"noreferrer noopener\">watch me do this on video.<\/a><\/em><\/p>\n\n\n\n<p>HTML is the language that web browsers (like Firefox, Chrome, and Safari) understand. It\u2019s a\u00a0<strong>markup language<\/strong>, meaning you annotate content with it so that the browser treats that content in different ways. (HTML\u00a0stands for\u00a0<em>hypertext markup language<\/em>, if you\u2019re curious.)<\/p>\n\n\n\n<p>It\u2019s not too hard to learn, and it\u2019s fun! As always, the hardest thing about this tutorial will be arranging windows on your screen so that you can see everything at once! In one browser window or tab, leave this tutorial open so that you can refer to it as you proceed.<\/p>\n\n\n\n<p>A sidebar on web accessibility: The principles you\u2019ll learn today will create a website that is accessible to people using screen-reading software. But as you progress in your web development, you\u2019ll want to read more explicitly about accessibility.&nbsp;<a href=\"https:\/\/www.w3.org\/TR\/WCAG21\/\">These<\/a>&nbsp;are the latest \u201cgold standard\u201d guidelines for accessibility, created by the W3C Web&nbsp;Accessibility&nbsp;Initiative.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a folder to store your web documents<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh201w22\/wp-content\/uploads\/sites\/20\/2019\/02\/Screen-Shot-2019-02-05-at-11.36.19-AM.png\" alt=\"A folder called &quot;my_website.&quot;\" class=\"wp-image-409\"\/><\/figure>\n\n\n\n<p>Putting all your website documents in one place will make it easier to stay organized. Create a new folder somewhere on your computer, preferably somewhere easy to find. You can give your folder any title you like. When you\u2019re dealing with code, though, avoiding spaces in file names often makes them easier to find.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get set up<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/miriamposner.com\/classes\/dh101f17\/wp-content\/uploads\/sites\/7\/2017\/09\/Screen-Shot-2017-11-01-at-10.37.24-AM.png\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh101f17\/wp-content\/uploads\/sites\/7\/2017\/09\/Screen-Shot-2017-11-01-at-10.37.24-AM.png\" alt=\"The Atom interface, showing a blank text document.\" class=\"wp-image-1994\"\/><\/a><\/figure>\n\n\n\n<p>Download&nbsp;<a href=\"https:\/\/atom.io\/\">Atom<\/a>&nbsp;and double-click it to open it. When you open Atom for the first time, three tabs will appear in the window.&nbsp;<em>Please close all the tabs except for the one called \u201cuntitled.\u201d<\/em><\/p>\n\n\n\n<p><strong>Atom<\/strong>&nbsp;is a (free) text editor, which is the name for the kind of program that you type code into. Just like Microsoft Word, it displays the text that you type. But unlike Microsoft Word, it doesn\u2019t (invisibly) surround your text with formatting information. So never&nbsp;use Microsoft Word for your code! Instead, use Atom or one of the many alternatives, like&nbsp;<a href=\"https:\/\/www.sublimetext.com\/\">Sublime<\/a>.<\/p>\n\n\n\n<p>Believe it or not, a plain text editor (like Sublime) and a web browser (like Chrome, Safari, or Firefox) are all you really need to build even the fanciest webpage!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Enter the document declaration and a little bit of text<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/miriamposner.com\/classes\/dh101f16\/wp-content\/uploads\/sites\/5\/2016\/10\/Screen-Shot-2016-10-25-at-4.41.29-PM-1.png\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh101f16\/wp-content\/uploads\/sites\/5\/2016\/10\/Screen-Shot-2016-10-25-at-4.41.29-PM-1.png\" alt=\"A text document open in Atom, alongside a browser displaying the same code.\" class=\"wp-image-1399\"\/><\/a><figcaption>The text won\u2019t look all beautiful and pink like it does in this image until you save your Atom text file as an HTML document.<\/figcaption><\/figure>\n\n\n\n<p>In this step, we\u2019ll type our first HTML code. This is what you\u2019ll type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n\n&lt;html&gt;\n\n&lt;head&gt;\n\n&lt;\/head&gt;\n\n&lt;body&gt;\n\n&lt;p&gt;Welcome to my webpage!&lt;\/p&gt;\n\n&lt;\/body&gt;\n\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>And here\u2019s what it all means:<\/p>\n\n\n\n<p>A&nbsp;<strong>document declaration<\/strong>&nbsp;gives instructions to the web browser (like Safari or Firefox) for how to handle the document you\u2019ve created. Luckily, they\u2019re easy to make. Just type<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html&gt;<\/pre>\n\n\n\n<p>at the very top of the document.<\/p>\n\n\n\n<p>Then press&nbsp;<strong>return&nbsp;<\/strong>and type in<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;html&gt;<\/pre>\n\n\n\n<p>to tell the browser to expect HTML in the document that follows. Then skip a few lines and&nbsp;<strong>close<\/strong>&nbsp;your html tag by typing<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;\/html&gt;<\/pre>\n\n\n\n<p>(Your browser won\u2019t care about spaces and returns inside the header.)<\/p>\n\n\n\n<p>It\u2019s considered good practice to divide up your webpage into&nbsp;<strong>head<\/strong>&nbsp;and&nbsp;<strong>body&nbsp;<\/strong>sections. Special instructions for the browser (if you have any) go in the head section. Content goes in the body section.<\/p>\n\n\n\n<p>To make these sections, press&nbsp;<strong>return<\/strong>&nbsp;and enter<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;head&gt;<\/pre>\n\n\n\n<p>somewhere inside your opening and closing &lt;html&gt; tags.<\/p>\n\n\n\n<p>After you create your head tag, leave a line or two blank and close your head tag by typing<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;\/head&gt;<\/pre>\n\n\n\n<p>Now make the&nbsp;<strong>body<\/strong>&nbsp;section. Below your&nbsp;<strong>&lt;head&gt;<\/strong>&nbsp;tag, type<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;body&gt;<\/pre>\n\n\n\n<p>Then skip a few lines and type<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;\/body&gt;<\/pre>\n\n\n\n<p>Let\u2019s put some text in, too, so we have something to look at. Type<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;p&gt;Welcome to my webpage&lt;\/p&gt;<\/pre>\n\n\n\n<p>after your opening body tag and before the closing body tag. Perhaps you remember what&nbsp;<strong>&lt;p&gt;<\/strong>&nbsp;stands for:&nbsp;<strong>paragraph<\/strong><\/p>\n\n\n\n<p><strong>Save<\/strong>&nbsp;your document to the folder you created in the first step. Name it&nbsp;<strong>index.html<\/strong>. By default, web browsers will look for an index.html file to display first.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">View your document in your web browser<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh201w22\/wp-content\/uploads\/sites\/20\/2019\/02\/Screen-Shot-2019-02-05-at-9.52.04-AM-1.png\" alt=\"Code editor open in one window and browser open in the other.\" class=\"wp-image-402\"\/><figcaption>To display your index.html file in a web browser, simply double-click it.<\/figcaption><\/figure>\n\n\n\n<p><strong>Leave your Atom document open<\/strong>&nbsp;and navigate to where you saved your index.html file. Double-click the icon for the file you saved. By default, that&nbsp;file should open up in a browser.<\/p>\n\n\n\n<p>Now you should have index.html open in two different ways: 1) as a webpage and 2) as a text file, displayed in Atom.<\/p>\n\n\n\n<p>Arrange your windows so you can see the index.html open as a text document and as a webpage, simultaneously.<\/p>\n\n\n\n<p>On your text document, alter the text between the paragraph tags so that it says something different and&nbsp;<strong>save&nbsp;<\/strong>the document. Now click&nbsp;<strong>Refresh<\/strong>&nbsp;on your web browser. The text on the webpage should show the new text you\u2019ve saved.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Add a header<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh201w22\/wp-content\/uploads\/sites\/20\/2019\/02\/Screen-Shot-2019-02-05-at-9.52.04-AM.png\" alt=\"Displaying a header by opening and closing h1 tags.\" class=\"wp-image-392\"\/><\/figure>\n\n\n\n<p>By default,&nbsp;<strong>headers<\/strong>&nbsp;instruct browsers to treat text inside the tags differently, to signal that it\u2019s important. Add a header to your page by putting some text in<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;h1&gt;<\/pre>\n\n\n\n<p>tags, somewhere above your paragraph tags. (Remember to both open and close them.) Save the document and refresh your browser. You should now have a header on your page! Looking good.<\/p>\n\n\n\n<p>You can also use<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;h2&gt;<\/pre>\n\n\n\n<p>tags, which are a bit smaller, and<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;h3&gt;<\/pre>\n\n\n\n<p>tags, which are smaller still, all the way to<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;h5&gt;<\/pre>\n\n\n\n<p>tags. Experiment with different-sized headers, saving and refreshing as you go.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How links work<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/dh101f15\/wp-content\/uploads\/2015\/10\/media_1445643187364.png\" alt=\"Links work by opening a tag with &quot;a href,&quot; inserting the link in quotation marks, closing the opening brackets, typing the text of your link, and then closing the a tag.\"\/><\/figure>\n\n\n\n<p>What\u2019s a webpage without a link? They work like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;a href=\"www.google.com\"&gt;text of your link&lt;\/a&gt;<\/pre>\n\n\n\n<p>In the example above,&nbsp;<strong>www.google.com<\/strong>&nbsp;is the URL to which you want to link and&nbsp;<strong>text of your link<\/strong>&nbsp;is the text that actually appears as a hyperlink.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a link on your page<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh201w22\/wp-content\/uploads\/sites\/20\/2019\/02\/Screen-Shot-2019-02-05-at-9.55.45-AM.png\" alt=\"A link displayed in the code editor and on a webpage.\" class=\"wp-image-393\"\/><\/figure>\n\n\n\n<p>Try it yourself by creating a new paragraph (using the opening and closing &lt;p&gt; tags) and creating a link within your new paragraph. Save your document, refresh your browser and test your link!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How images work<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh201w22\/wp-content\/uploads\/sites\/20\/2019\/02\/Screen-Shot-2019-02-05-at-11.05.47-AM.png\" alt=\"Images can be displayed either by entering a path in the img tag or by linking to an image on another site.\" class=\"wp-image-396\"\/><\/figure>\n\n\n\n<p>You can link to an image in one of two ways. If there\u2019s an image out there on the Web that you\u2019d like to embed on your page, you can grab the link to the image by right-clicking on the image and clicking&nbsp;<strong>Copy Image URL<\/strong>. Then you can embed the image by pasting the link, as above.<\/p>\n\n\n\n<p>If you have an image on your computer that you\u2019d like to use, you can save it&nbsp;<strong>in the same folder where your html file is saved<\/strong>&nbsp;and link directly to it by entering the file name, as above.<\/p>\n\n\n\n<p>(When you enter the file name in an image tag, you\u2019re actually providing a&nbsp;<strong>path<\/strong>&nbsp;to an image: that is, telling your browser where to find the image in order to display it. Because you\u2019ve saved your image in the same place as your HTML document, you can just type the name of the file. Read more about paths&nbsp;<a href=\"https:\/\/learn-the-web.algonquindesign.ca\/topics\/paths-folders\/\">here<\/a>.)<\/p>\n\n\n\n<p>You should also provide \u201calt text\u201d for your image: a brief description of an image for people who are using text-to-speech readers or in case your image breaks. The alt text won\u2019t be displayed unless the image breaks, but a person using a text-to-speech reader will be able to hear it. You can read more about writing good alt text&nbsp;<a href=\"https:\/\/www.abilitynet.org.uk\/blog\/five-golden-rules-compliant-alt-text\">here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Add an image<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh201w22\/wp-content\/uploads\/sites\/20\/2019\/02\/Screen-Shot-2019-02-05-at-10.04.09-AM.png\" alt=\"Image tag created in the code and displayed in the browser.\" class=\"wp-image-394\"\/><\/figure>\n\n\n\n<p>Add an image to your webpage using one of the two methods from the previous step.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Add some emphasis<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh201w22\/wp-content\/uploads\/sites\/20\/2019\/02\/Screen-Shot-2019-02-05-at-11.07.52-AM-1024x632.png\" alt=\"Em and strong tags created in the code and displayed in the browser.\" class=\"wp-image-397\"\/><\/figure>\n\n\n\n<p>Sometimes you want to highlight particular text on your page, to indicate that the browser should treat it differently. Common tags for this are<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;em&gt;<\/pre>\n\n\n\n<p>(which stands for&nbsp;<strong>emphasis<\/strong>; by default, your browser will italicize the text inside this tag) and<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;strong&gt;<\/pre>\n\n\n\n<p>(by default, your browser will bold the text inside this tag). For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;p&gt;My students are &lt;em&gt;excellent&lt;\/em&gt; and &lt;strong&gt;awesome&lt;\/strong&gt;!&lt;\/p&gt;<\/pre>\n\n\n\n<p>Create more text and experiment with emphasis and headers. Just remember to always close those tags!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">But wait! No one can see your page!<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/miriamposner.com\/classes\/dh201w22\/wp-content\/uploads\/sites\/20\/2019\/02\/Screen-Shot-2019-02-05-at-11.09.49-AM.png\" alt=\"A website displayed via a link to a local file.\" class=\"wp-image-398\"\/><\/figure>\n\n\n\n<p>If you look closely at the URL on your webpage, you\u2019ll see that it looks funny: it starts with<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/<\/pre>\n\n\n\n<p>not<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">http:\/\/<\/pre>\n\n\n\n<p>That\u2019s because you\u2019re working on your file&nbsp;<strong>locally<\/strong>, meaning just on your own computer. No one else can see your webpage at the moment.<\/p>\n\n\n\n<p>In order for other people to see your file, it has to be&nbsp;<strong>hosted on a server<\/strong>, meaning moved to a special computer whose job is to broadcast files to the internet. You don\u2019t have a server yet, but you will in the fourth tutorial of today!<\/p>\n\n\n\n<p>Before we get to that, though, let\u2019s&nbsp;<a href=\"http:\/\/miriamposner.com\/classes\/dh201w21\/tutorials-guides\/web-development\/paint-that-page-with-css\/\">l<\/a><a href=\"http:\/\/miriamposner.com\/classes\/is270s23\/resources\/web-design\/paint-that-page-with-css\/\" data-type=\"page\" data-id=\"276\">ook at how you can make your page look more exciting<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can also watch me do this on video. HTML is the language that web browsers (like Firefox, Chrome, and Safari) understand. It\u2019s a\u00a0markup language, meaning you annotate content with&hellip; <a class=\"more-link\" href=\"http:\/\/miriamposner.com\/classes\/is270s23\/resources\/web-design\/build-a-webpage-from-scratch-with-html\/\">Continue reading <span class=\"screen-reader-text\">Build a webpage from scratch with HTML<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":272,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_eb_attr":"","footnotes":""},"class_list":["post-274","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"http:\/\/miriamposner.com\/classes\/is270s23\/wp-json\/wp\/v2\/pages\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/miriamposner.com\/classes\/is270s23\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/miriamposner.com\/classes\/is270s23\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/miriamposner.com\/classes\/is270s23\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/miriamposner.com\/classes\/is270s23\/wp-json\/wp\/v2\/comments?post=274"}],"version-history":[{"count":0,"href":"http:\/\/miriamposner.com\/classes\/is270s23\/wp-json\/wp\/v2\/pages\/274\/revisions"}],"up":[{"embeddable":true,"href":"http:\/\/miriamposner.com\/classes\/is270s23\/wp-json\/wp\/v2\/pages\/272"}],"wp:attachment":[{"href":"http:\/\/miriamposner.com\/classes\/is270s23\/wp-json\/wp\/v2\/media?parent=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}