Can you make a website with html for free?
// Tutorial Series // Show
How To Build a Website with HTML IntroductionIntroductionIf you are interested in learning how to build and design websites, Hyper Text Markup Language (HTML) is a great place to start. This project-based tutorial series will introduce you to HTML and its methods by building a personal website using our demonstration site (below) as a model. Once you learn the basics, you will know how change the website’s design and add personalized content. No prior coding experience is necessary to follow along the tutorials in this series. HTML is the standard markup language used to display documents in a web browser. First developed by Tim Berners Lee in 1990 while working at the European Organization for Nuclear Research (CERN), HTML was one of the key innovative technologies used to publish the world’s first website on August 6, 1991. Thanks to a restoration project by CERN, you can now revisit the original website. Since that time, HTML has been significantly updated and expanded but its basic purpose to format and structure web pages remains the same. Today, HTML is one of many tools used to build the web. Knowing how to write HTML will provide a strong foundation for your career as a web designer and prepare you to learn additional front-end web development skills like CSS and JavaScript. In this tutorial series, you’ll learn how to create and customize a website using common HTML tags and techniques. After finishing this tutorial, you’ll have a site ready to deploy to the cloud. Prerequisites
Once you have your prerequisites ready, you will be ready to set up your HTML project in the next tutorial. Summary View detailed View // Tutorial //To explore HTML in practice and begin building an HTML website, we’ll need to set up a new project using a text editor. This tutorial series uses Visual Studio Code, a free code editor available for Mac, Windows, or Linux, but you may use whichever code editor you prefer. After opening your preferred text editor, open up a new project folder and name it To create a new project folder in Visual Studio Code, navigate to the “File” menu item in the top
menu and select “Add Folder to Workspace.” In the new window, click the “New Folder” button and create a new folder called Next, create a new file called You now have a project folder and file for exploring HTML. We’ll return to this file in the tutorials ahead. Debugging and Troubleshooting CSS and HTMLBefore we get started with our HTML exercises, be aware that precision is important when writing HTML. Even an extra space or mistyped character can keep your code from working as expected. If your HTML code is not rendering in the browser as intended, make sure you have written the code exactly. To troubleshoot errors, check for extra or missing spaces, missing or misspelled tags, and missing or incorrect punctuation or characters. Each time you change your code, make sure to save your file before reloading it in the browser to check your results. A Quick Note on Automatic HTML Support FeaturesSome code editors—such as the Visual Studio Code editor that we’re using in this series—provide automatic support for writing HTML code. For Visual Studio Code, that support includes smart suggestions and auto completions. While this support is often useful, be aware that you might generate extra code that will create errors if you’re not used to working with these support features. If you find these features distracting, you can turn them off in the code editor’s preferences. We are now ready to begin learning how the CSS language works. In the next tutorial, we’ll begin exploring how CSS rules are used to control the style and layout of HTML content on a webpage. // Tutorial //This tutorial will introduce you to a basic HTML document and teach you how to view the source code of an HTML document in a browser. HTML is used to mark up a document with instructions that tell a browser how to display and interpret the document’s content. For example, HTML can tell the browser which text content should be interpreted as a heading
and which text content should be interpreted as paragraphs. HTML is also used to add images and assign links to text and images. These instructions are communicated through HTML tags, which are written like this: To get a sense of how these tags are used, let’s inspect a snippet of HTML code. The HTML code below shows how HTML tags are used to structure text and add links and images. Don’t worry if you don’t understand the tags immediately- we’ll study those in the next tutorial.
This HTML code is rendered in the browser as follows: You should now have an understanding of how the HTML example code is rendered in a browser. Next, we will learn how to view the source code of any webpage using a browser tool. Viewing the Source Code of a WebpageNearly every webpage you come across uses HTML to structure and display HTML pages. You can inspect the source code of any webpage by using a web browser like Firefox or Chrome. On Firefox, navigate to the “Tools” menu item in the top menu and click on “Web Developer/Page Source” like so: On Firefox, you can also use the keyboard shortcut On Chrome, the process is very similar. Navigate to the top menu item “View” and click on “Developer/View Source.” You can also use the keyboard shortcut Try inspecting the source code of the demo website that we will build in this tutorial series. You should receive a page with many more HTML tags than our example above. Don’t be alarmed if it seems overwhelming. By the end of this tutorial series, you should have a better understanding of how to interpret HTML source code and how to use HTML to build and customize your own websites. Note: As mentioned above, you can inspect the source code of any webpage using tools from the Firefox or Chrome web browser. Try inspecting the code of a few of your favorite websites to get a sense of the underlying code that structures web documents. Though the source code of these sites will likely contain more languages than HTML, learning HTML first will help prepare you to learn additional languages and frameworks for creating websites later on if you wish. You should now have a general understanding of the format of an HTML document and know how to inspect HTML source code using a browser tool. To better understand how HTML works, let’s inspect its key components. In the next tutorial, we will learn more about HTML elements, the building blocks that are used to create HTML documents. // Tutorial //HTML documents are composed of HTML elements. Most HTML elements contain content (such as text or an image) along with HTML tags that tell the browser how to interpret the content (such as a heading or paragraph text). HTML elements can be used to add structure, semantics, and formatting to different parts of an HTML document. An HTML element is often created—but not always—by opening and closing HTML tags, which wrap around a piece of content. Below is an illustration that labels each of the parts of an HTML element: Let’s try exploring HTML in practice. Try pasting the following line into your “index.html” file that you created when Setting Up Your HTML Project:
In this example, the Note: You may note that the Similarly, the emphasis tag To check the results of this HTML code, we can load the “index.html” file in our browser. Though your file is not online, the browser will still be able to interpret the HTML file as if it were a web page document. Make sure to save your “index.html” file before loading it in the browser as only saved updates will be rendered. How To View an Offline HTML File In Your BrowserYou can view an offline HTML file in the browser in several ways:
If you are using the Visual Studio Code text editor, you can copy the file path using <$>[note] Note: To load the file in the browser, it’s important that you copy the absolute path, (which refers to the file location relative to the root directory), rather than the relative path, (which refers to the file relative to the current working directory). In Visual Studio Code, “Copy Path” refers to the full file path. Be aware, however, that we will use relative paths of files in other parts of this tutorial. After loading the file in your browser, you should receive a page that contains the following: My strong text Let’s try experimenting with other HTML elements. On the next line of your “practice.html” file, try adding the
Save the file and reload the file in the browser. You should receive something like this: My strong text My emphasized text The first phrase should be styled with strong formatting and the second phrase should be styled with emphasis. However, you may be surprised by the side-by-side placement of the two phrases. If you added This tutorial will teach you the difference between inline-level and block-level elements in HTML and how they affect a piece of content’s position on the page. When arranging elements in an HTML document, it’s important to understand how these elements take up space on a webpage. Certain elements can take up much more space on the webpage than the content they contain. Understanding the behavior of different element types will help you anticipate how they affect the position of other elements on the page. In general, there are two different types of elements—inline-level elements and block-level elements—whose spacing defaults behave differently from one another. Below, we’ll describe how the default settings of these elements determine their position on the webpage and relative to the position of nearby elements. Inline-level ElementsInline elements are elements whose horizontal width is determined by the width of the content they contain. The We can use Firefox’s Web Developer Inspector to inspect the size of HTML elements on a webpage. (If you are using Chrome, you can use the Developer Inspect Elements tool instead but this tutorial will give instructions for Firefox’s Web Developer tool.) Return to the Then navigate to the Tools menu item in the top menu bar and select “Web Developer/Inspector.” Selecting this menu item will open up the Inspector interface that allows you to inspect the HTML and CSS of a webpage. Next, hover your cursor over the text Unlike block-level elements, which we’ll
cover in the next section, inline elements do not take up their own line of horizontal space. Thus, inline elements will rest side by side on a webpage if you do not specify a break with an additional HTML element, such as the line break Try adding the
Save and reload the document in your browser to check your results. You should receive something like this: My strong text My emphasized text Your two phrases should now be on separate lines as they are now separated by the line break element
If you use the Firefox Web Developer Inspector to check the size of the elements, you can confirm that the width of each of the text elements is still determined by the width of the text content: ![Inspect Element again] (https://assets.digitalocean.com/articles/how-to-build-a-website-with-html/inspect-element2-min.gif) Block-level ElementsBlock-level elements behave differently than inline-level elements in that they take up an entire line of horizontal space on a webpage. This means that they automatically start on a new line and that they automatically push subsequent elements onto a new line as well. For example, the HTML heading elements ( Let’s study how this works in practice. At the bottom of your
Save your file and reload it in the browser. You should receive something like this: Let’s now inspect the block-level heading elements to study how they differ from the inline-level text elements above. Open up the Firefox Web Developer Inspector and hover over each of the elements to inspect their occupied space as indicated by the blue highlighting. You should be able to confirm that the occupied horizontal space of each of the inline-level elements is determined by its text content, while the occupied horizontal space of each of the block-level elements stretches across the entire web page: Block-level elements will always push inline-level elements down to the next line, even if you write those HTML elements on the same line of the HTML document. To confirm this for yourself, try writing a block-level element and an inline-level element on the same line of your
Can you guess how this HTML code will render in the browser? Save your file and reload it in the browser. You should receive something like this: Notice that the heading element You should now have an understanding of how inline-level and block-level elements are positioned and how they affect the position of nearby elements. Remembering their distinct behaviors can be useful when arranging HTML elements in the future. We’ll continue learning about new inline and block elements in the tutorials ahead. // Tutorial //This tutorial will teach you how to nest HTML elements in order to apply multiple HTML tags to a single piece of content. HTML elements can be nested, meaning that one element can be placed inside another element. Nesting allows you to apply multiple HTML tags to a single piece of content. For example, try pasting the following code snippet inside your
Save your file and reload it in the browser. (For instructions on creating an My bold text and my bold and emphasized text Nesting Best PracticesNote
that it is recommended to always close nested tags in the reverse order that they were opened.
As a counter example, the following HTML code contains tags that are not nested according to best practices, as the
While not technically necessary for rendering your HTML in the browser, nesting your tags in the proper order can help improve the readability of your HTML code for you or other developers. // Tutorial //HTML attributes can be used to change the color, size, and other features of HTML elements. For example, you can use an attribute to change the color or size of a font for a text element or the width and height for an image element. In this tutorial, we’ll learn how to use HTML attributes to set values for the size and color properties of HTML text elements. An HTML attribute is placed in the opening tag like this:
One common attribute is Using the Style AttributeWe can change multiple
properties of an
Before we load the file in our browser, let’s review each of the parts of this HTML element:
Note that the properties and values are contained by quotation marks, and that each Save the file and reload it in your browser. (For instructions on loading the file in your browser, see our tutorial here.) You should receive something like this: This text is 40 pixels and green.You have now learned how to use the Then, copy the file path of the image and replace Note: Make sure to copy the relative or
project file path of the image rather than the absolute or full file path of the image. The relative path refers to the file location relative to the current working directory (as opposed to the absolute path, which refers to the file location relative to the root directory.) While both paths will work in this instance, only the relative path would work if we decided to publish our website online. Since our end goal is to create a publishable website, we will
start using relative paths now when adding Technically, you can also use links to images hosted online as file paths. To understand how this works, try replacing the image location with a link to our image of Sammy the Shark like this:
Save your file and reload it in the browser. The image should still load in your web document, but this time the image is being sourced from its online location rather than your local project directory. You can experiment with adding other online images by using their location links as the For a useful guide on determining whether an image is informative or decorative, visit https://www.w3.org/WAI/tutorials/images/decision-tree/ You should now have familiarity with how to add images to your HTML document and how to add alternative text to aid with accessibility. We’ll learn how to change the image size and style in the tutorial How To Add a Profile Image To Your Webpage later on in the series. In the next tutorial, we’ll learn how to add links to an HTML document. // Tutorial //This tutorial will walk you through the steps of adding hyperlinks to your webpage. Hyperlinks can be added to text or images with the anchor link element
Try adding the code snippet below to your “index.html” file and changing the sample highlighted text with a real link, such as
(If you have not been following the tutorial series, you can review instructions for setting up an You should receive an output like this: You can also link images by wrapping an image element with an element like so:
Try testing the code snippet in your browser to check that it works. You should now understand how to add hyperlinks to text and images on your webpage. // Tutorial //How To Use a Published on July 28, 2020 · Updated on August 9, 2021 The HTML Content Division element
( On its own, the The Notice that the Save the file and reload it in the browser. (For instructions on loading the file in your browser, see our
tutorial here.) You should receive a red box with a width of 300 pixels and a height of 200 pixels like this: You can also add content to a Save the file and reload it in the browser. You should receive something like this: You can also put Save the file and reload it in the browser. You should receive something like this: Note that Save the file and reload it in the browser.
You should receive something like this: You should now have a basic understanding of how You can use HTML to modify the color of some elements and pieces of content of a webpage. For example, you can change
the color of text, a border, or—as demonstrated in the tutorial on HTML Content Division—of a In this tutorial, you will learn how to change the color of text, image borders, and The color of text elements, such as Try writing this code in your You should receive something like this: This is blue text. The color of a border is modified by using the Try writing this code in your You should receive something like this: The color of a Try writing
this code in your In these examples, the color value is defined by color names. Try changing the color of text, image borders and Note that colors can also be specified by hexadecimal
values. A hexadecimal color consists of six alphanumeric digits preceded by a pound symbol, such as You should now have a basic familiarity with how to change the color of text, image borders, and
The first thing to do when creating a new website project is to create a project directory (or folder) to store all the files that will be created in the process. This tutorial will walk you through the steps of setting up folders and files necessary for building your website with HTML. For this website project, we can continue using the Note: If you decide to choose your own name for the directory, make sure to avoid character spaces, special characters (such as !, #, %, or others), and capital letters, as these can cause problems later on. Next,
we’ll format the This declaration tells the browser which type of HTML is being used and is important to declare as there are multiple versions of HTML. In this declaration, Next,
we’ll add the Your document should now look like this: From this point forward, all content that we add to our website will be added between the opening and closing We will begin adding content to our site in the next tutorial. Published on July 28, 2020 · Updated on August 9, 2021 This tutorial will walk you through the steps of adding a Note:The HTML Add the opening and closing Note that you have nested a variety of HTML elements inside one another. The Let’s now pause briefly to understand the purpose of the code we’ve just added. The line of code after the opening The next line of code sets the HTML document’s title using the Though developers often add additional information in the You should now know
the purpose of HTML In this tutorial, we will walk through the steps involved in adding a favicon to your webpage using HTML. You can use any image you like for your favicon, but keep in mind that simple, high-contrast images often work best given the favicon’s small size. You can also generate a custom favicon through sites like favicon.cc. A favicon is a small image that is located in the browser tab to the left of a webpage’s title. The image below illustrates the location of a favicon. To add a favicon to your site, create a folder in your project directory called Next, add the Make sure to replace You should now know how to add favicon images to websites using HTML. Published on July 28, 2020 · Updated on August 9, 2021 The HTML To
add a You should now understand the purpose of an HTML In the next step, we’ll begin to add our website content in between the We will
now begin adding content by replicating the top section of the demonstration website. This top section is composed of a large background image, a small profile image, a text header, a text subheader, and a link. Each of these pieces of content are styled and positioned with
HTML. In the remaining tutorials of this series, we’ll learn how to use HTML to recreate this content on a new webpage. In this tutorial we’ll learn how to use a Before we get
started, we’ll need a background image. You may download and use our demonstration site’s background image for the purpose of the tutorial, or you can choose a new image. (For a refresher on how to add images to webpages using HTML, please visit our tutorial HTML Images from earlier in this tutorial series). Once you’ve
chosen your background image, save the image in your Next, paste the highlighted code snippet into your Make sure to switch the text that says Note that we have added the comment We have also specified the Save the file and reload it
in the browser. You should receive something like this: Alternately, you can use a background color instead of a background image. To use a background color, replace the Save the file and reload it in the
browser to check your results. The background image should now be replaced with a container that is the same size but has a solid yellow color. If you compare the To remove this margin, we need to add a style attribute to the opening Save and reload the file in your browser. There should now be no white margin surrounding the top You should now know how to add a
In this tutorial, we’ll walk through the steps of adding and styling the top profile image as displayed in the demonstration website. Before we get
started, you may want to pick a personal profile photo for including on your site. If you don’t have a profile photo, you can use any image for demonstration purposes or create an avatar through a site like Getavataaars.com. Otherwise, you can use the image from our demonstration site by downloading the image here. (For a refresher on how to add images to
webpages using HTML, please visit our tutorial How To Add Images To Your Webpage Using HTML from earlier in this tutorial series.) Once you’ve selected an image, save it as Paste the following highlighted Your profile image should appear as 150 pixels tall given the height we specified with the Add the highlighted properties to your Make sure you still have the correct file path of your image listed as the Before moving on, let’s briefly pause to study the code modifications we just made. Setting the You should now know how to add and style a profile
image to your website with HTML. We are now ready to add a title and subtitle to the webpage in the next tutorial. Published on July 29, 2020 · Updated on August 9, 2021 In this
tutorial, we will add and style a title and subtitle to our homepage. For the demonstration site, we’re using Sammy’s name and Sammy’s professional title, but you can add any content here that you like. For this content, we’ll use the Paste the following highlighted code snippet after your profile The elements used in this code snippet apply some light styling to our title and subtitle. However, we’ll need to add additional style values if we want the
style of our title and subtitle to match the style of the demonstration site. To make these modifications, we’ll add the Save your file and reload it in the browser. You should receive something like this: These style properties adjust the font size to 30 pixels and change the font color to white. We have also added a margin of 10 pixels to the You should now know how to add and style a title and subtitle to your webpage with HTML. In the next tutorial, we’ll learn how to create and link to an additional webpage on your website. Published on July 29, 2020 · Updated on August 9, 2021 When building a website, you may want to have more than one webpage. If you want to add and link to additional pages, you’ll need to
first create a new Our demonstration website includes an “About” webpage. In this tutorial, we’ll walk you through the process of creating and linking to an “About” webpage, but you may change the title and the content of this page to fit your needs. To add a new page to your website,
create a new file named Note: If you decide to choose your own name for the file, make sure to avoid character spaces, special characters (such as !,
#, %, or others), and capital letters as these can cause problems later on. You must also include the Next, you’ll need to format the file by adding information that will help the browser interpret the file content. To format the file, add following code snippet at the top of the document: Make sure to change the highlighted text with a title you want for you page. For an explanation of each of the HTML tags, please visit the earlier tutorial in this series
Adding an HTML Before adding any content to this page, let’s walk through the steps of adding a link to this page on your homepage. First, return to your Change the
highlighted file path to the relative file path of your “about.html” file. The relative path refers to the file location relative to the current working directory (as opposed to the absolute path, which refers to the file location relative to the root directory.) If you are using the Visual Studio Code text editor, you can copy the relative file path by Note that we have also specified a font-size and color using the
You should now have a link that directs to your If you receive an error, make sure that your file is in the same project directory as your You should now know how to
create and link to a new webpage on your website. You can use these same steps to create and link to additional webpages on your website. You can also add content to any new webpage in the same way you are learning to add content to your homepage. Aligning content to the center, left, or right can be useful for arranging content on your page. In this tutorial, we’ll learn how to align text using HTML. To align text on a webage, we can use the
For example, the following code snippet would center the text “Sample text”: To align your HTML content to the left or right, you would replace In this tutorial, we’ll go through the process of using the To center this content, we’ll add the Locate this Only copy and add the highlighted You should now understand how to center and align text and have a section that looks like the top section of the demonstration site. In the next tutorial, we will recreate the middle section of the demonstration site. Published on July 29, 2020 · Updated on August 9, 2021 In this tutorial, we will recreate the body or middle section of our demonstration website using HTML The middle section of our demonstration website contains a large profile image and a short paragraph of text displayed side by side. We can achieve this layout by using First, we’ll add a large profile
image as displayed in the demonstration site. Before we start, make sure you have selected a large profile image or other image to use. We’ll be displaying our image at 400 by 600 pixels, so make sure your image size will work with those dimensions. If you do not have an image, you can download the image from our demo site. Once you have your image, save it in your images folder. (For a refresher on how to add
images to webpages using HTML, please visit our tutorial HTML Images from earlier in this tutorial series). Next, copy the following code snippet after the last closing Let’s pause briefly to review each part of this code snippet: Save your “index.html” file and reload it in the browser. The section below the top section of your webpage should now look like this: If you have errors, check to make sure that you have added all the HTML code in the correct area of the Next, we will add a paragraph of text to the right of the image. Feel free to substitute the dummy text in this example with text of your own choosing. We will create this text section by creating a In your “index.html” file, add the following code snippet after the
image you added in the step above and before the closing Let’s pause briefly to review each part of this code snippet: Save your “index.html” file and
reload it in the browser. The section below the top section of your webpage should now look like this: Your image and text should now be displayed as they are in the demonstration website. You may adjust the style properties in the code snippets to change the height, margins, font size or other style properties of your content. Note
that if your browser viewport is shrunk extensively, your text will eventually flow over into other elements on your page. To create layouts that are responsive to a range of devices, you’ll need to learn additional front end skills such as CSS (tutorial series coming soon) and Flexbox. You should now have an understanding of how to arrange images and text side by side using A website footer is the final block of content at the bottom of a webpage. Footers can contain any type of HTML content, including text, images, and links. In this final tutorial of the series, we’ll create the following basic footer for our webpage using a To get started, paste the following code snippet after your closing In this snippet, We have also added text content and an emoji inside the Save your file and reload it in the browser to check the results. You should receive something like this: Notice that our footer content is not quite like the one in the demonstration site.
Our footer content has a white bottom margin and the text has different styling. To remove the bottom margin and style the text, add the highlighted attributes to your Save the file and reload it in the browser. You should now have a footer styled in the same manner as the demonstration site pictured at the top of this tutorial. In this tutorial you have learned how to create and style a footer. You can now explore adding different types of content
and styling to your footer using elements from this tutorial series. When you share links on social media platforms, they’ll often be presented with rich imagery and a nicely formatted title, summary, and link, instead of plain text. For instance, here is how Twitter would display a link to this tutorial series: You can add these rich media social sharing capabilities to your site by including certain In this tutorial you will learn how to add both Twitter Card and Open Graph metadata to your webpage. Twitter Cards are a metadata specification used by Twitter to display rich text,
imagery, and video when links are shared on the service. The full Twitter Card markup specification has many options, but you can start with the most basic information and expand from there. To add basic Twitter Card metadata to your site, place the following Be sure to update the highlighted
portions with your own information. Let’s walk through each tag we just added: This metadata should result in a Twitter Card that looks like the
following: For more information on other Twitter Card tags and options, visit the official Twitter Cards documentation. The Open Graph protocol is an open standard for metadata that many websites use to display rich link previews to their users. Sites like Facebook, LinkedIn, and Pinterest use Open Graph to display links. The markup for Open Graph is similar to Twitter Cards: some Place these tags in the More information on the Open Graph protocol is available on the official Open Graph protocol website. There are a few tools you can use to preview how your
meta tags would display on a website. The Open Graph Debugger is an unofficial simulator that shows both Twitter Card and Open Graph information, and doesn’t require an account to use. The following official validators all require you to log into their service before using: Many other sites have similar tools. If a site or community is important to you or your business, look for their developer documentation to see if they provide a
similar service to test with. You now know how to set up a minimal set of metadata to show rich link formatting on various social sites. Refer to the Twitter Cards and Open Graph documentation for more detailed information. Congratulations, you have
now built a website using HTML. You should now be familiar with how HTML elements, tags, content dividers, and attributes work and know how to structure HTML web pages, format text, and add images, links, and comments. Feel free to continue modifying your site by adding additional content and styling. For some ideas on getting started, you may be interested in: To learn how to publish your site for free using DigitalOcean’s App Platform, visit our tutorial
How To Deploy a Static Website to the Cloud with Digital Ocean’s App Platform. If you are interested in further developing your website development skills, we suggest you follow our tutorial series How To Build a Website With
CSS. On its own, HTML is limited in its capacity and is not meant to be used to style a website. Today, most websites are developed with HTML and CSS, the Cascading Stylesheet language, along with a number of other tools and frameworks. Once you have a basic understanding of HTML and CSS, you will be ready to explore many other exciting web development tools that can be used along with them. Want to teach this series in a remote or in-person workshop? Check out our
How To Build a Website With HTML Workshop Kit that has everything you need to teach a ninety-minute workshop, including slides, speaker notes, and a landing page to help participants get started. Check out all our Tutorial Series Join our DigitalOcean community of over
a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest. Sign up |