- Creating An Html File
- Your First Webpage
- Creating index.html
- Tags
- Container vs Non-Container Tags
- Learning the Code
- Making Changes
- Setting Up CSS and HTML for Your Website: A Tutorial
- Prerequisites
- Step 1- Initial Set Up
- Step 2- Adding HTML Content in the index . html File
- Step 3- Styling Using CSS
- Conclusion
- About Akshay Nagpal
- Proud member of
- Privacy Overview
Creating An Html File
HTML is a markup language which browsers use to determine how a webpage should be displayed. By learning HTML, you’ll be able to write code which describes the look and feel of a website you’re trying to build.
All of this HTML code is going to be contained inside a .html file. This is any file which has a .html extension. Most text editors you’re used to using will most likely not be able to save files into the .html format. Therefore the first thing I would recommend doing is downloading an IDE that supports HTML. See the previous lesson for a full introduction on how to do this!
Once you’re set up with your IDE we can start creating our first HTML file!
Your First Webpage
When we’re working in HTML we’re creating web-pages. HTML documents are meant to be read and processed by a web browser. In order to create a website that it organized properly, we’ll want to make sure that all of the HTML files we create are inside the same folder.
Let’s begin by creating an empty folder for all of our HTML files going forward in the course. You can call it whatever you want, most people will name it the same as their website.
Now that we have an empty folder we can create our HTML file. If your IDE supports it, I would recommend adding this new folder to the IDE’s file explorer or workspace. This will make it easier to see what’s going on without having to leave the editor.
Creating index.html
Inside the new folder create a file named index.html . index.html is a special file name which indicates that this is the default webpage for this directory of our website.
Just like most people organize their files into folders and sub-folders, websites are also organized in this same way. When your website is run by the browser it will use the directory of the HTML file to determine the web page’s URL. This URL is either relative to your local file system, or to your hosted website.
Now that we have our file created, let’s add some text in it and test it out on the browser. Inside index.html type Hello World .
This is the most basic form a website can take, just some plain text written out.
Now find index.html in your file system and open it with your browser. There should be an option to do this, and usually by default .html files will open in your browser if you double click them.
Whe the page loads on the browser it should say Hello World !
Believe it or not you’ve just created your first website. It’s really basic and only has a few words on it, but it’s still a website and you’ve made your first step towards becoming a web developer.
Tags
While our current website is impressive in it’s own right, it’s not technically a properly structured HTML document. HTML documents are all required to be structured in a certain way to ensure that they will display correctly in all different versions of different browsers.
Our HTML document, with only plain text, will display fine, but if we try to do anything more complex we run the risk of some older browsers not understanding the page.
In order to make this a proper HTML document let’s format it correctly.
Copy Hello World
Take a look at the updated HTML document above. This is now structured correctly, and should be understandable by every browser.
Now, your first thought is most likely What are those weird >things. It’s a good thought, if this is your first time seeing HTML code then you’ll be wondering what those are.
Those symbols with the < and >signs are called tags. HTML tags are used to structure and format the HTML document, and can be used to describe the layout of a website.
All of the content in our webpage is going to be contained in these tags. There are hundreds of HTML tags, although luckily most of the time you can get by with only knowing 10-15 of them. All tags have names associated to them, and depending on what you’re trying to display on the webpage you’ll use a different tag.
Container vs Non-Container Tags
There are two basic types of tags in HTML, container tags and non-container tags.
Container Tags are comprised of two tags that go together, an opening and a closing tag. In the example above we have a bunch of container tags. Take a look at the . tags and you’ll get an idea of how these work.
All tags are comprised of a <. >, with the name of the tag being printed in the middle. End tags are special because they contain a / right before the name of the tag (as you can see in