- How TO — Make a Website
- Create a Website from Scratch
- A «Layout Draft»
- Navigation bar
- Side Content
- Main Content
- Footer
- First Step — Basic HTML Page
- Example
- My Website
- Example Explained
- Creating Page Content
- Header
- My Website
- Navigation Bar
- Content
- Footer
- Footer
- W3Schools Spaces
- Introduction
- Setup Our Project
- Let’s Start Our Project
- Introduction of HTML
- This is what it looks like when opened in a browser 👇
- Introduction of CSS
- The rules for declaring CSS
- For Adding Class
- Hello HTML Class Attribute Here class attribute is appended to the starting tag of with equal sign (=) and after = we add class name under quotation mark. For Adding Id Hello HTML Id Attribute Here class attribute is appended to the starting tag of with equal sign (=) and after = we add id name under quotation mark. After selecting a selector we open the curly brace, then we add the properties we want to style such as color, font, border, etc. Then we add the colon right after the property and then we add the value for that property, then end with a semicolon and the close curly brace. CSS can be added to HTML in 3 ways — 1. Inline CSS , 2. Internal CSS, 3. External CSS. 1. Inline Css Hello World ! To use inline css in html we need to use attribute. HTML attributes are special words used inside the opening tag to control the element’s behaviour. 2. Internal CSS Usually we use internal CSS when we make a one page website. It is defined with a style element under the tag. 3. External CSS For external css we create a new file with extension .css and link that page to html using link attribute. It is generally good practice to use external CSS and generate clean code as well. After creating the css file we can simply add the style with css. Now we have to add the css file to our portfolio website, after adding the css file our website looks like this👇 Previously we finished the HTML part, now we have to add the CSS, To add the css file we create a css external file named style.css then we have to link that page with html. For links we have to use attribute in tag. After creating style.css file we start our styling. body < background-color: rgb(255, 232, 155); text-align: center; margin-top: 6%; >p < font-family: "Courier New", Courier, monospace; font-size: 20px; >a < text-decoration: none; color: #fff; >ul < list-style-type: none; >table, th, td < background-color: #fff; margin-left: 28%; border: 1px solid black; padding: 10px; >button < padding: 10px; >#fb < background-color: #3b5998; >#link < background-color: #0077b5; >#git Lets understand the above css code, first we style our body with some background color for that we use CSS background-color property with value rgb(255, 232, 155) or you can write your favorite color code or name. After styling the background color, we now style our text position, for this we use the CSS text-align property with a value of center or you can choose different values (left, right, etc). Now we style the margins with CSS margin-top property with a value of 6%, the margin-top property creates margins only from the top, if we only use the margin property they create margins from all sides. Now we style the paragraph from selecting a tag with CSS font-family property with a value of «Courier New», Courier, monospace, the font-family property changes the font style of paragraph, after styling the font style now we also style the size of font with CSS font-size property with value 20px. Источник
- with equal sign (=) and after = we add class name under quotation mark. For Adding Id Hello HTML Id Attribute
- For Adding Id
- Hello HTML Id Attribute
- with equal sign (=) and after = we add id name under quotation mark. After selecting a selector we open the curly brace, then we add the properties we want to style such as color, font, border, etc. Then we add the colon right after the property and then we add the value for that property, then end with a semicolon and the close curly brace. CSS can be added to HTML in 3 ways — 1. Inline CSS , 2. Internal CSS, 3. External CSS. 1. Inline Css Hello World !
- 1. Inline Css
- Hello World !
- 2. Internal CSS
- 3. External CSS
How TO — Make a Website
Learn how to create a responsive website that will work on all devices, PC, laptop, tablet, and phone.
Create a Website from Scratch
A «Layout Draft»
It can be wise to draw a layout draft of the page design before creating a website:
Navigation bar
Side Content
Main Content
Footer
First Step — Basic HTML Page
HTML is the standard markup language for creating websites and CSS is the language that describes the style of an HTML document. We will combine HTML and CSS to create a basic web page.
Example
My Website
A website created by me.
Example Explained
- The declaration defines this document to be HTML5
- The element is the root element of an HTML page
- The element contains meta information about the document
- The element specifies a title for the document
- The element should define the character set to be UTF-8
- The element with name=»viewport» makes the website look good on all devices and screen resolutions
- The element contains the styles for the website (layout/design)
- The element contains the visible page content
- The element defines a large heading
- The
element defines a paragraph
Creating Page Content
Inside the element of our website, we will use our «Layout Draft» and create:
- A header
- A navigation bar
- Main content
- Side content
- A footer
Header
A header is usually located at the top of the website (or right below a top navigation menu). It often contains a logo or the website name:
My Website
A website created by me.
Then we use CSS to style the header:
.header <
padding: 80px; /* some padding */
text-align: center; /* center the text */
background: #1abc9c; /* green background */
color: white; /* white text color */
>
/* Increase the font size of the element */
.header h1 font-size: 40px;
>
Navigation Bar
A navigation bar contains a list of links to help visitors navigating through your website:
Use CSS to style the navigation bar:
/* Style the top navigation bar */
.navbar overflow: hidden; /* Hide overflow */
background-color: #333; /* Dark background color */
>
/* Style the navigation bar links */
.navbar a float: left; /* Make sure that the links stay side-by-side */
display: block; /* Change the display to block, for responsive reasons (see below) */
color: white; /* White text color */
text-align: center; /* Center the text */
padding: 14px 20px; /* Add some padding */
text-decoration: none; /* Remove underline */
>
/* Right-aligned link */
.navbar a.right float: right; /* Float a link to the right */
>
/* Change color on hover/mouse-over */
.navbar a:hover background-color: #ddd; /* Grey background color */
color: black; /* Black text color */
>
Content
Create a 2-column layout, divided into a «side content» and a «main content».
We use CSS Flexbox to handle the layout:
/* Ensure proper sizing */
* box-sizing: border-box;
>
/* Column container */
.row <
display: flex;
flex-wrap: wrap;
>
/* Create two unequal columns that sits next to each other */
/* Sidebar/left column */
.side flex: 30%; /* Set the width of the sidebar */
background-color: #f1f1f1; /* Grey background color */
padding: 20px; /* Some padding */
>
/* Main column */
.main <
flex: 70%; /* Set the width of the main content */
background-color: white; /* White background color */
padding: 20px; /* Some padding */
>
Then add media queries to make the layout responsive. This will make sure that your website looks good on all devices (desktops, laptops, tablets and phones). Resize the browser window to see the result.
/* Responsive layout — when the screen is less than 700px wide, make the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 700px) .row <
flex-direction: column;
>
>
/* Responsive layout — when the screen is less than 400px wide, make the navigation links stack on top of each other instead of next to each other */
@media screen and (max-width: 400px) .navbar a float: none;
width: 100%;
>
>
Tip: To create a different kind of layout, just change the flex width (but make sure that it adds up to 100%).
Tip: Do you wonder how the @media rule works? Read more about it in our CSS Media Queries chapter.
Tip: To learn more about the Flexible Box Layout Module, read our CSS Flexbox chapter.
What is box-sizing?
You can easily create three floating boxes side by side. However, when you add something that enlarges the width of each box (e.g. padding or borders), the box will break. The box-sizing property allows us to include the padding and border in the box’s total width (and height), making sure that the padding stays inside of the box and that it does not break.
You can read more about the box-sizing property in our CSS Box Sizing Tutorial.
Footer
At last, we will add a footer.
Footer
.footer <
padding: 20px; /* Some padding */
text-align: center; /* Center text*/
background: #ddd; /* Grey background */
>
Congratulations! You have built a responsive website from scratch.
W3Schools Spaces
If you want to create your own website and host your .html files, try our website builder, called W3schools Spaces:
Introduction
Web development is the work involved in developing a Web site for the Internet (World Wide Web). From building a personal website to building a social media web app, everything is a web development work and HTML and CSS are the beginning of everything you need to know to make your first web page. At the end of this blog, your first personal portfolio website will be ready.
Setup Our Project
First we need to set our project folder in our PC and after creating the folder we open that folder in any IDE (in my case I use VS Code), you can choose whatever you want. After opening the folder in IDE, we need to create files with .html extension for HTML file and .css for CSS file. VS-Code
Let’s Start Our Project
Introduction of HTML
HTML is the hypertext markup language used to create the website structure and its content. Headlines, paragraphs, tables, links, images in a website are all done with HTML.
Let’s understand from code, open your project on IDE and in HTML file, write this code and open in your browser( right click and click Open in browser ).
This is what it looks like when opened in a browser 👇
Start with This declaration defines that this document is an HTML5 document. HTML & HTML 5 both are same. HTML 5 are just updated version of HTML.
This declaration defines to declare the language of the Web page.
The element contains meta information about the HTML page.
Meta data may be used by browsers (content or methods of page reloading), search engines (keywords), or other web services, including keywords for page information, the author of the document, last modified, and metadata.
title element specifies a title for the HTML page (which is shown in the browser’s title bar or in the page’s tab). Using JavaScript you can change the title dynamically.
body tag is the main part or element of HTML document. It contain text content, paragraphs, headings, images, tables, links, videos, etc.
Now, in body tag we struct all the parts of website.
Now, let’s start building our website structure. we start from heading, in HTML heading define with to tag.
define most important heading or largest font size heading and is for least important heading or smallest font size heading. After creating heading with to tag, now we move to paragraph where we use
tag to create paragraph in HTML. Above code you see that we put a heading in tag.
The tag is also known as the division tag, it makes it easy to create different divisions for websites like navbar, header, sidebar and footer etc. I used tag for main title and tag for sub-heading, After title you see there is
tag which is used for paragraph.
Now after heading and paragraph let us see how we create table in HTML, as you see in the code i have again used tag for education title and after that i have used tag which is used to create a table in HTML. In tag we use tag which defines table row where we write our data, In the first tag we use tag which defines the table title, we add three titles in the first tag (degree, college, year), after that we put a content according to its title in the next tag and In the second tag we use the tag which defines the data cell in the HTML table. There are two types of cells in HTML table, first- header cell ( ) and second is data cell ( ). According to our table header we put our data in the data cell.
Now after completing our table we move on to learn about unordered list and ordered list.
To create a list we have to use
- tag or
tag which defines the order of the list.
- defines an unordered list (bullet) for a list (collection of items) with no numeric or alphabetical order and
defines an ordered list which means that the collection of data (list) is numerically or alphabetically. Now we come to our last part of our website where we create our contact section where people can click on buttons to find you in different social media. Yes it is possible using HTML where people click on a button and that button send that user to your social media page. To create a button we use the tag which defines a clickable button. In button we can put different HTML tags or texts. In this project we put anchor tag tag that defines a hyperlink that links one page to another. In this anchor tag we will put social media link then when people click on button then that tag will take them directly to that page. Now we are finally done with our HTML code 👇 , as earlier we have learned that HTML only forms the structure of our website but currently our website is not looking good so to beautify our website we need to use CSS What needs to be done is to make our website look good by giving it some color, margin and padding etc.
Introduction of CSS
CSS stands for Cascading Style Sheet , it is a style sheet language used to stylize our website by selecting HTML elements by adding colors, layouts and fonts. It also helps in adapting the presentation to different devices like large screen, small screen.
The rules for declaring CSS
We have to choose which HTML elements we want to style, that element is called selector. we can select that element directly but when we need to select some specific section to style then we create a class or id for the element then we select that class or id and then style them. To create a class or id we need to add class attribute or id attribute to the html element.
For Adding Class
Hello HTML Class Attribute
Here class attribute is appended to the starting tag of
with equal sign (=) and after = we add class name under quotation mark. For Adding Id
Hello HTML Id Attribute
Here class attribute is appended to the starting tag of
with equal sign (=) and after = we add id name under quotation mark.
After selecting a selector we open the curly brace, then we add the properties we want to style such as color, font, border, etc. Then we add the colon right after the property and then we add the value for that property, then end with a semicolon and the close curly brace. CSS can be added to HTML in 3 ways — 1. Inline CSS , 2. Internal CSS, 3. External CSS.
1. Inline Css
Hello World !
To use inline css in html we need to use attribute. HTML attributes are special words used inside the opening tag to control the element’s behaviour.
2. Internal CSS
Usually we use internal CSS when we make a one page website. It is defined with a style element under the
tag.3. External CSS
For external css we create a new file with extension .css and link that page to html using link attribute. It is generally good practice to use external CSS and generate clean code as well.
After creating the css file we can simply add the style with css.
Now we have to add the css file to our portfolio website, after adding the css file our website looks like this👇
Previously we finished the HTML part, now we have to add the CSS, To add the css file we create a css external file named style.css then we have to link that page with html. For links we have to use attribute in tag. After creating style.css file we start our styling.
body < background-color: rgb(255, 232, 155); text-align: center; margin-top: 6%; >p < font-family: "Courier New", Courier, monospace; font-size: 20px; >a < text-decoration: none; color: #fff; >ul < list-style-type: none; >table, th, td < background-color: #fff; margin-left: 28%; border: 1px solid black; padding: 10px; >button < padding: 10px; >#fb < background-color: #3b5998; >#link < background-color: #0077b5; >#git
Lets understand the above css code, first we style our body with some background color for that we use CSS background-color property with value rgb(255, 232, 155) or you can write your favorite color code or name.
After styling the background color, we now style our text position, for this we use the CSS text-align property with a value of center or you can choose different values (left, right, etc).
Now we style the margins with CSS margin-top property with a value of 6%, the margin-top property creates margins only from the top, if we only use the margin property they create margins from all sides.
Now we style the paragraph from selecting a
tag with CSS font-family property with a value of «Courier New», Courier, monospace, the font-family property changes the font style of paragraph, after styling the font style now we also style the size of font with CSS font-size property with value 20px.