Today most of the websites use content management systems such as WordPress, Joomla, and OpenCart to be built and people tend to skip the essentials of the website creation process – the HTML and the CSS.
In the following article, we will guide you through the process of creating a responsive HTML5 and CSS3 website from scratch.
Building Website From Scratch HTML5 And CSS3
For the purpose of our tutorial, we will create 2 files – index.html and style.css and a folder that is going to store our images and we are going to name “img“.
The index.html file is where our HTML code is going to be. It is used for the “skeleton” of the website and it holds the main information about the website, the meta descriptions, the links to other files, and pretty much everything without stylings.
The style.css is the file that holds the styling of our page. It is going to be used for defining our styles, positioning, layouts, and the overall outlook of our website. For a better understanding of the structure of the code, we will break it down to pieces and explain every piece or line of code that you are going to use.
Every HTML5 document starts with the following lines of code:
The <!DOCTYPE html> tells the browsers that this document is going to be using HTML5, the metacharset specifies the encoding of the document and we highly recommend keeping it to UTF-8. On some rare occasions if you are creating a website on a different language you might need to change that if you experience problems with displaying your language characters.
The meta name = “viewport” property tells the browser that the website is going to have a responsive behavior.
The link to google fonts lets your HTML document use google fonts for its texts and the link rel=” stylesheet” line of code links the style.css document to your HTML document, enabling you to apply the styles from your .css file straight to your HTML.
Body Of The HTML Website
The “body” of every HTML website, or <body> is where all of your content stays. The HTML <body> tag defines the main content of the HTML document or the section of the HTML document that will be visible on your web page when its opened.
We will start our website by creating a body and including a header in it.
This is the skeleton for our header and it includes an <header< which is the tag that is used for the header of every website. It holds the top of the website with its navigation.
Before proceeding, let’s take a minute to explain what a CSS class means.
What is a CSS Class?
A CSS class is a group of elements that share the same attributes, such as color or font-size. These attributes are specified to the class and can be applied to different elements. For example, we have a class “nav-link” that we use for every element in our menu and thus every navigation link in our menu will look and behave like every other navigation link that has that class on it.
We’ve included our logo within a div, that has a class “logo-container“.
An <h4> (meaning Heading 4) with a class of “logo” and a div with a class of “cart” that will be used for displaying the cart image.
Building The Main
The <main></main> tag specifies the main content of our document. This element should be unique to the element and it should not contain any repeated content such as sidebars, navigation, logos, and search forms.
In our <main> </main> we have a <section> with a class named
“presentation“, a div with a class “introduction“, a div with another class <“intro-text”> and Heading 1 <h1> and a paragraph <p>. The classes are going to apply different styles for our elements. (more about that in the CSS part of the article).
The <img> tags are used for linking and displaying images, and we also added them some CSS class styling.
Once we are done with that, we are ready with the skeleton of our website. However, our website will now look very bad because it does not have its stylings done.
Styling Our Website
All of the stylings of our website are being written and saved in the style.css file. This file is a .css file that stores only CSS code and defines the visual part of our HTML layout, elements, classes, and ids.
The first thing that we wanna do in our styles.css file is to write down:
These lines of code are used to fix any margin or padding problems, and border-box as well. Once you’ve done that step, you can proceed with the styling of our <header>. To select the <headergt; element, simply use the
The display: flex property will move everything in one line.
The width:90% will make our header element to take 90% of the total width of our body. The margin: auto will figure out the proper space between the element and its parent container and adjust its position perfectly. The align-items: the center will position all of the child items that are in our <headergt; in its center.
Logo container, nav links, and cart
CSS is a very flexible and powerful language and it allows us to apply stylings to more than 1 class of elements. For example, we can apply the display: flex property to our logo-container, nav-links, and cart classes with a single line of code:
These lines of CSS will grant some stylings to the .nav-link class, making the navigation color to teal, with larger font-size, remove the underline, increase the logo font-size to 400.
The justify-content: flex and will move the cart image to the end of its container and you are done with your header.
Proceeding with the styling of our presentation and introduction classes.
That will allow us to display the items flexed and position them side by side. We can then proceed with styling the intro-text h1, settings its font-size, font-weight, and giving it a background of a gradient as well.
This will apply stylings to the text h1 and text paragraphs as well, giving them some margin and a font-size of 22px as well as a #585772 color.
Styling the Call To Actions
These lines of code will select the .cta elements and will give them proper stylings as well, changing the width, height, border, cursor, color, etc. The margin option will give some spacing away from the button from its top, right, bottom, left.
Once we get to this point our website already starts to look good.
Styling The Cover Image
These lines of CSS will make our laptop fit in the center of its container and also give it some shadow and a popup animation.
Positioning Background Circles
We want to put our circle images in the background of our page, so we can use the following CSS code:
This will let us put the circles in the background with different positions and reduced opacity, so our page will look much better and much more professional.
Styling the Arrows
For the styling of our arrows, we will use
Giving them a width of 15% of their container, display: flex, position absolute so we can position them where ever we want and right of 20%, sending them to the right side of our page.
We will create a simple animation with the help of @keyframes.
Our code starts with an opacity of 0, or not being visible and start from a bit up, let’s say -80px, and when the animation finishes we want our animation to go to 0px. This will create a very nice and beautiful effect on our laptop when our page loads.
Making Our Website Mobile Friendly
What we’ve created for now is a decent looking page that fits a laptop or a desktop user, but this will not look good on mobile devices.
To do that, we should use the media queries provided by the CSS and write down some rules, that will be applied depending on the screen size of our device.
Starting with a
the max-width:1024 property defines where the following rules should be applied. In other words, when the screen size becomes smaller than 1024px, the new set of rules will be applied and the website will change its look.
The flex-direction: the column will apply to the class .presentation and thus it will be position its elements 1 under another.
Then, we can proceed with applying some more rules under our
These stylings will transform your website’s layout to fully responsive and give it its completed look.
Building a website from scratch is not that hard as long as you understand the way HTML and CSS work together.
Creating HTML elements and styling them with CSS selectors is a crucial knowledge that you should possess if you are about to start building websites.
Follow the steps below to create a website:
What do you need before starting a website.
Before starting site setup process, we strongly advise that you complete the following preparation steps:
- Have a clear idea for the site's domain name. For example, good tip is to make it short and with focused keywords.
- Make sure to have an active credit or debit card so that you can make online purchases with it.
- Make sure you prepare a computer that has stable internet connection.
Step 1: Purchase a domain name and web hosting type.
Step 2: Install WordPress and an appropriate visual theme for your website.
FAQ’s How to Create a Website
What is a Website?
A website is mainly made from web pages that contain related content all classified by a unique domain name (A domain name is your website name. It is the address where Internet users can access your website). On a website, you can post contrasting content connected with the sphere of your website.
There are different types of websites, which you can find on the networking space like:
Interesting Fact: The first website uploaded on the internet went live on August 6, 1991.
How Much Does It Cost to Create a Website?
To find out how much it will cost to create a website, firstly you need to have a clear idea about the type of your website. What it is going to be: e-commerce, blog, educational, etc.
After choosing the best hosting provider, it's time for the right theme for your site, and the plugins, then you can estimate how much it will cost to start your website.
Have in mind that if there are FREE web hosting and free WordPress themes available out there.
Do I Need Any Programing Knowledge for Creating a Website?
Probably yes. Creating a website is not an easy task, and it is good to have some programming knowledge if you are considering creating one, BUT there are also alternatives that you can use for creating your website without having any programming knowledge.
One very popular alternative that you can use is to install a responsive multi-purpose WordPress theme like Avada and set drag & drop page buider, which will help you to customize your website at ease.
Can I Create a Website for FREE?
Once upon a time, it was said that everything is possible, so creating a website for free is possible, although it's hard to achieve without any expense.
To start your free website creation you need to find a free WordPress theme like Astra and to install it on free hosting service like OOOWebHost. After you have already hosted your website on the internet you need to install free plugins, which is the most difficult part. It is problematic to find reliable free plugins. There are some free available like Yoast SEO that can do pretty nice work, but most reliable plugins like WPRocket, which are required for the success of your website are not free.
How Long Does It Take to Create a Website?
This is a question that concerns everyone who is considering making a website. The truth is that there is no specific answer to this question and everything depends on the height of your goal. If you are thinking off creating a small blog you can make your website in a day. But if you are considering making a big online shop or something similar you will need to spend a lot more time.
Which Are the Best Platforms for Creating a Website?
The easiest way to create a website is to use a CMS(Content Management System) website builder platforms like WordPress or Joomla. The CMS platforms can help you create and customize your website without having much coding knowledge.
The Most Popular CMS Platforms:
What Is HTML? - Quick Tutorial.
HTML is the standard markup language used in the web pages, with which you can create your own website. Using the base of the HTML and CSS(Cascading Style Sheets - another web language with which you can put style over the HTML fundamental) languages can be very helpful for making little customization changes to your website.
HTML Code Examle
HTML Element Example
What Is Web Hosting
A web hosting service is a type of Internet hosting service that allows individuals and organizations to upload their websites on the internet. There are different types of hosting services like:
- Shared Hosting (Server shared between many users)
- Dedicated Hosting (A dedicated server only for you)
- VPS Hosting (Virtual Private Server)
- Cloud Hosting (Hosting services that are provided to customers via multiple connected servers that comprise a cloud)