{"id":654,"date":"2020-01-02T19:08:42","date_gmt":"2020-01-03T00:08:42","guid":{"rendered":"http:\/\/newmediaproduction.mynmi.net\/?page_id=654"},"modified":"2025-05-20T17:59:44","modified_gmt":"2025-05-20T17:59:44","slug":"html-tags","status":"publish","type":"page","link":"https:\/\/nmi.cool\/webdev\/html-tags\/","title":{"rendered":"HTML Tags"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large is-resized is-style-rounded is-style-rounded--1\"><img loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"1707\" src=\"https:\/\/nmi.cool\/newmediaproduction\/wp-content\/uploads\/sites\/14\/2020\/01\/caspar-camille-rubin-fPkvU7RDmCo-unsplash-scaled-1.jpg\" alt=\"Close up image of a laptop computer with code visible on the screen.\" class=\"wp-image-948\" style=\"aspect-ratio:1.7777777777777777;object-fit:cover;width:816px;height:auto\" srcset=\"https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/01\/caspar-camille-rubin-fPkvU7RDmCo-unsplash-scaled-1.jpg 2560w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/01\/caspar-camille-rubin-fPkvU7RDmCo-unsplash-scaled-1-300x200.jpg 300w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/01\/caspar-camille-rubin-fPkvU7RDmCo-unsplash-scaled-1-1024x683.jpg 1024w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/01\/caspar-camille-rubin-fPkvU7RDmCo-unsplash-scaled-1-768x512.jpg 768w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/01\/caspar-camille-rubin-fPkvU7RDmCo-unsplash-scaled-1-1536x1024.jpg 1536w, https:\/\/nmi.cool\/webdev\/wp-content\/uploads\/sites\/14\/2020\/01\/caspar-camille-rubin-fPkvU7RDmCo-unsplash-scaled-1-2048x1366.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><figcaption class=\"wp-element-caption\">Photo by&nbsp;<a href=\"https:\/\/unsplash.com\/@casparrubin?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Caspar Camille Rubin<\/a>.<\/figcaption><\/figure>\n\n\n\n<p>Open a new HTML file in Visual Studio Code and save it as <strong>tags.html<\/strong> locally in your playground folder.<\/p>\n\n\n\n<p>Copy and paste the <a href=\"https:\/\/nmi.cool\/webdev\/html-boilerplate\/\">HTML boilerplate<\/a> or let VSC autofill the boilerplate for you by typing html and then selecting <code>html:5<\/code> from the dropdown options.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n&lt;meta charset=\"UTF-8\"&gt;\n&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n&lt;title&gt;Document&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>Within the <code>&lt;body&gt;&lt;\/body&gt;<\/code> tags, copy and paste the following code (do not include the &lt;body&gt; tags below as those are already in your boilerplate):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;body&gt; \n    &lt;h1&gt;Main Heading&lt;\/h1&gt;\n &nbsp;&nbsp;&nbsp;&lt;h2&gt;Subheading&lt;\/h2&gt;\n &nbsp;&nbsp;&nbsp;&lt;h3&gt;Another Slightly Smaller Subheading&lt;\/h3&gt;\n &nbsp;&nbsp;&nbsp;&lt;p&gt;This is the paragraph section&lt;\/p&gt;\n&lt;\/body&gt; <\/code><\/pre>\n\n\n\n<p>Save your work (click <em>\u2318<\/em>+s if you&#8217;re on a Mac or Control+S if you&#8217;re on a Windows machine). Once it&#8217;s saved, right-click on the test.html file that you just created and click &#8220;Open with Chrome&#8221; to preview your work. <sup data-fn=\"a22d84d9-9348-47dc-a613-dc7d0f747003\" class=\"fn\"><a href=\"#a22d84d9-9348-47dc-a613-dc7d0f747003\" id=\"a22d84d9-9348-47dc-a613-dc7d0f747003-link\">1<\/a><\/sup> Hey, you made a webpage! Pretty cool, right? It should look like what you see below (with different fonts).<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h1 class=\"wp-block-heading\">Main Heading<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Subheading<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Another Slightly Smaller Subheading<\/strong><\/h3>\n\n\n\n<p>This is the paragraph section.<\/p>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">HTML Elements<\/h3>\n\n\n\n<p>HTML elements are how developers structure the content and information on websites. You&#8217;ve seen them before in brackets: <strong><code>&lt; &gt;<\/code><\/strong>. Everything inside those brackets are called an HTML element. <br><br>For instance, <code>&lt;body&gt;&lt;\/body&gt;<\/code> is an HTML element. Elements are often, but not always, made up of an opening tag (<code>&lt;body&gt;<\/code>) and a closing tag (<code>&lt;\/body<\/code>). <br><br>Can you tell the difference between the opening and closing tags? The forward slash, <strong><code>\/<\/code><\/strong>,&nbsp; indicates the closing tag. HTML elements tell the browser how to display the content placed in between the tags.<br><br>For instance, <code>&lt;h1&gt;<\/code> is telling the browser this is a main heading<sup data-fn=\"6bdb6574-8cd1-447b-a290-b78d1b5b2980\" class=\"fn\"><a href=\"#6bdb6574-8cd1-447b-a290-b78d1b5b2980\" id=\"6bdb6574-8cd1-447b-a290-b78d1b5b2980-link\">2<\/a><\/sup>. The browser knows everything from <code>&lt;h1&gt;<\/code> to <code>&lt;\/h1&gt;<\/code> is main heading. <br><br><code>&lt;h2&gt;<\/code> is telling the browser the words from <code>&lt;h2&gt;<\/code> to <code>&lt;\/h2&gt;<\/code> should be displayed as a subheading. And so on and so forth! <br><br>You can think of tags as boxes. The opening tag (<code>&lt;p&gt;<\/code>) is a box, and the closing tag (<code>&lt;\/p&gt;<\/code>) is the box lid. Everything inside the box is what you specify it to be.<\/p>\n\n\n\n<p>Those letters in the tags (h1, h2, p, etc) aren\u2019t random. These characters are part of the HTML syntax<sup data-fn=\"8020bab9-0841-49b1-987d-03c6454897cc\" class=\"fn\"><a href=\"#8020bab9-0841-49b1-987d-03c6454897cc\" id=\"8020bab9-0841-49b1-987d-03c6454897cc-link\">3<\/a><\/sup> and express the tag\u2019s purpose.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Hold up! What even is HTML?<\/h3>\n\n\n\n<p>HTML files control the <strong>structure<\/strong> of web pages.<br><br>HTML5, HyperText Markup Language, is the standard markup language of the web. These HTML tags are called \u201cmarkup.\u201d HyperText describes the way that HTML files use links to quickly jump around.<\/p>\n\n\n\n<p><a aria-label=\"Free Code Camp (opens in a new tab)\" href=\"https:\/\/www.freecodecamp.org\/learn\/responsive-web-design\/basic-html-and-html5\/\" target=\"_blank\" rel=\"noreferrer noopener\">Free Code Camp<\/a> also offers a nice description of HTML:<\/p>\n\n\n\n<p>The HyperText part of HTML comes from the early days of the web and its original use case. Pages usually contained static documents that contained references to other documents. These references contained hypertext links used by the browser to navigate to the reference document, so the user could read the reference document without having to manually search for it.<\/p>\n\n\n\n<p>As web pages and web applications grow more complex, the W3 Consortium updates the HTML specification to ensure that a webpage can be shown reliably on any browser. The latest version of HTML is HTML5.<\/p>\n\n\n\n<p>For more background info about HTML, check out this <a aria-label=\"article. (opens in a new tab)\" href=\"https:\/\/www.theserverside.com\/definition\/HTML-Hypertext-Markup-Language\" target=\"_blank\" rel=\"noreferrer noopener\">article.<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">White space<\/h3>\n\n\n\n<p>White space can make your code cleaner and easier to read. Your browser will <strong>not <\/strong>display this white space, so feel free to indent or add spaces to your heart\u2019s content.<\/p>\n\n\n\n<p>Fun tip: If your browser comes across two spaces next to each other, it only displays one space.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!doctype html&gt; \n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n&lt;meta charset=\"UTF-8\"&gt;\n&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;     \n   &lt;title&gt;Hello world!&lt;\/title&gt; \n&lt;\/head&gt; \n   &lt;body&gt; \n    &lt;h1&gt;Main&nbsp;Heading&lt;\/h1&gt;\n &nbsp;&nbsp;&nbsp;&lt;h2&gt;Subheading&lt;\/h2&gt;\n &nbsp;&nbsp;&nbsp;&lt;h3&gt;Another Slightly Smaller Subheading&lt;\/h3&gt;\n &nbsp;&nbsp;&nbsp;&lt;p&gt;This is the&nbsp;paragraph section&lt;\/p&gt;\n   &lt;\/body&gt; \n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>Displays the same as:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> &lt;body&gt;\n &nbsp;&nbsp;&nbsp;&lt;h1&gt;Main\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Heading&lt;\/h1&gt;\n &nbsp;&nbsp;&nbsp;&lt;h2&gt;Subheading   &lt;\/h2&gt;\n &nbsp;&nbsp;&nbsp;&lt;h3&gt;Another&nbsp; &nbsp; Slightly    Smaller &nbsp; Subheading&lt;\/h3&gt;\n &nbsp;&nbsp;&nbsp;&lt;p&gt;This is the&nbsp; &nbsp; paragraph section&lt;\/p&gt;\n &lt;\/body&gt; <\/code><\/pre>\n\n\n\n<p>That being said, please don&#8217;t format your HTML the second way\u2014that&#8217;s just to illustrate the point that white space doesn&#8217;t impact your output.<\/p>\n\n\n\n<p>This is true of your entire HTML file, not just the body section. Throughout the semester, try to keep your code organized and easy to scan. It\u2019s best practice <strong>NOT <\/strong>to put all of your code on one line, like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> &lt;body&gt;\n &nbsp;&nbsp;&nbsp;&lt;h1&gt;Main Heading&lt;\/h1&gt;&lt;h2&gt;Subheading&lt;\/h2&gt;&lt;h3&gt;Another Slightly Smaller Subheading&lt;\/h3&gt;&lt;p&gt;This is the paragraph section&lt;\/p&gt;\n &lt;\/body&gt; <\/code><\/pre>\n\n\n\n<p>Can you tell why? <strong>It\u2019s hard to read.<\/strong> You can\u2019t tell where one HTML element is closing and another one begins.<sup data-fn=\"66ab40c8-a645-44ac-88de-6e99df2662e7\" class=\"fn\"><a href=\"#66ab40c8-a645-44ac-88de-6e99df2662e7\" id=\"66ab40c8-a645-44ac-88de-6e99df2662e7-link\">4<\/a><\/sup><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Formatting Your HTML<\/h3>\n\n\n\n<p>Being aware of how white space works in an HTML document is important for writing code that&#8217;s easy to read, but indenting and formatting your HTML properly is equally important.<\/p>\n\n\n\n<p>You can check out some best practices for <a href=\"https:\/\/www.granneman.com\/webdev\/coding\/formatting-and-indenting-your-html\" target=\"_blank\" rel=\"noreferrer noopener\">formatting and indenting your HTML<\/a> here. When your code is easy to read it makes YOUR life easier, and it makes it much easier for your instructor to assess your work&#8211; and out in the &#8220;real world&#8221; writing code is often a collaborative process where teammates or clients might need to see what&#8217;s going on under the hood. Build good habits right from the beginning and make sure your code is tidy and easy to read by following <a href=\"https:\/\/www.granneman.com\/webdev\/coding\/formatting-and-indenting-your-html\" target=\"_blank\" rel=\"noreferrer noopener\">these<\/a> guidelines!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Your turn!<\/h3>\n\n\n\n<p>In your VS Code test document, try out the following challenges! <strong><br><br><\/strong>A) How many levels of headings (<code>h1<\/code>, <code>h2<\/code>, <code>h3<\/code>, etc) can you find in HTML? Type them in test.html and see!<br>B) How do you create more paragraphs? Hint: you will have to repeat certain tags. <br>C) What happens when you add text in between these elements: <code>&lt;b&gt;<\/code> type some text in here <code>&lt;\/b&gt;<\/code><br>D) What happens when you add text in between these elements: <code>&lt;em&gt;<\/code> and <code>&lt;\/em&gt;<\/code>? How about <code>&lt;i&gt;<\/code> and <code>&lt;\/i&gt;<\/code>?&nbsp;<br>E) <code>&lt;hr\/&gt;<\/code> is an element that only has <strong>one tag <\/strong>rather than an opening and closing. Add it between your two paragraphs. What does it do? <br><br>When you\u2019re done, be sure to save your file and refresh your Chrome browser window to see what you created.<\/p>\n\n\n\n<p>If you get stuck, click page 2 for some hints! <br><\/p>\n\n\n\n<!--nextpage-->\n\n\n\n<p><strong>Answers: <\/strong><\/p>\n\n\n\n<p>A) Six <br>B) By closing one paragraph with the closing tag <code>&lt;\/p&gt;<\/code>), and starting the new paragraph with another opening tag: <code>&lt;p&gt;<\/code>.&nbsp;<br>C) The <code>&lt;b&gt;<\/code> tag makes words bold.&nbsp;<br>D) The <code>&lt;em&gt;<\/code> tag italicizes words. If you used <code>&lt;i&gt;<\/code> you&#8217;d get the same result, but <code>&lt;em&gt;<\/code> is used when you want to emphasize a word whereas &lt;i&gt; indicates the text should be in italics, like a book title, but doesn&#8217;t mean it&#8217;s especially important. <br>E) <code>&lt;hr\/&gt;<\/code> displays a horizontal line<\/p>\n\n\n<ol class=\"wp-block-footnotes\"><li id=\"a22d84d9-9348-47dc-a613-dc7d0f747003\">If Chrome isn&#8217;t on the list of options to open the file with, no worries! First, make sure you have Chrome downloaded onto your computer. If you do, but it still isn&#8217;t showing up under the &#8220;Open with&#8221; options, click &#8220;Other&#8221; at the bottom of the &#8220;Open with&#8221; list and search for Chrome. Select it and click Open. <a href=\"#a22d84d9-9348-47dc-a613-dc7d0f747003-link\" aria-label=\"Jump to footnote reference 1\">\u21a9\ufe0e<\/a><\/li><li id=\"6bdb6574-8cd1-447b-a290-b78d1b5b2980\">Fun fact: You typically only have 1 (or less) h1 element per page as h1 is reserved for the top-most header, such as a page title. <a href=\"#6bdb6574-8cd1-447b-a290-b78d1b5b2980-link\" aria-label=\"Jump to footnote reference 2\">\u21a9\ufe0e<\/a><\/li><li id=\"8020bab9-0841-49b1-987d-03c6454897cc\">Syntax is like the set of rules that determine how you write the code.\u00a0It&#8217;s similar to grammar in a language,\u00a0where specific arrangements of words create meaningful sentences.\u00a0In HTML,\u00a0elements,\u00a0attributes,\u00a0and values must be organized in a specific way to create a well-formed webpage. <a href=\"#8020bab9-0841-49b1-987d-03c6454897cc-link\" aria-label=\"Jump to footnote reference 3\">\u21a9\ufe0e<\/a><\/li><li id=\"66ab40c8-a645-44ac-88de-6e99df2662e7\">It will take your instructor much, much longer to help you if your code is not formatted well. <a href=\"#66ab40c8-a645-44ac-88de-6e99df2662e7-link\" aria-label=\"Jump to footnote reference 4\">\u21a9\ufe0e<\/a><\/li><\/ol>","protected":false},"excerpt":{"rendered":"<p>Open a new HTML file in Visual Studio Code and save it as tags.html locally in your playground folder. Copy and paste the HTML boilerplate or let VSC autofill the boilerplate for you by typing html and then selecting html:5 from the dropdown options. Within the &lt;body&gt;&lt;\/body&gt; tags, copy and paste the following code (do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"[{\"content\":\"If Chrome isn't on the list of options to open the file with, no worries! First, make sure you have Chrome downloaded onto your computer. If you do, but it still isn't showing up under the \\\"Open with\\\" options, click \\\"Other\\\" at the bottom of the \\\"Open with\\\" list and search for Chrome. Select it and click Open.\",\"id\":\"a22d84d9-9348-47dc-a613-dc7d0f747003\"},{\"content\":\"Fun fact: You typically only have 1 (or less) h1 element per page as h1 is reserved for the top-most header, such as a page title.\",\"id\":\"6bdb6574-8cd1-447b-a290-b78d1b5b2980\"},{\"content\":\"Syntax is like the set of rules that determine how you write the code.\u00a0It's similar to grammar in a language,\u00a0where specific arrangements of words create meaningful sentences.\u00a0In HTML,\u00a0elements,\u00a0attributes,\u00a0and values must be organized in a specific way to create a well-formed webpage.\",\"id\":\"8020bab9-0841-49b1-987d-03c6454897cc\"},{\"content\":\"It will take your instructor much, much longer to help you if your code is not formatted well.\",\"id\":\"66ab40c8-a645-44ac-88de-6e99df2662e7\"}]"},"class_list":["post-654","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/pages\/654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/comments?post=654"}],"version-history":[{"count":20,"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/pages\/654\/revisions"}],"predecessor-version":[{"id":6131,"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/pages\/654\/revisions\/6131"}],"wp:attachment":[{"href":"https:\/\/nmi.cool\/webdev\/wp-json\/wp\/v2\/media?parent=654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}