How to Make a Website Responsive
Learn how to responsive web design with CSS media queries & mobile-friendly techniques. Create websites that adapt seamlessly to all devices. Expert guide!
Learn to build a website with HTML and CSS. This comprehensive guide covers everything from basic syntax to advanced styling techniques. Start your web development journey today!
Want to make your own spot on the internet? Building a website with HTML and CSS is a great place to begin! It's perfect for anyone who wants to learn about making websites. This guide will show you the basics. You'll learn how to build cool and useful websites.
Before we start writing code, let's talk about why you should learn HTML and CSS. They're super important for making websites.
HTML and CSS work together. They create the websites we use every day. Learning these things is a big step if you want to be a front-end development pro.
To start building your website with HTML CSS, here's what you need:
That's all you need! No fancy stuff. Just a text editor and a browser.
HTML uses tags to make different parts of a webpage. Tags look like this: <
and >
. Most tags come in pairs. One opens, and one closes. The closing tag has a slash (/
).
Here's some basic HTML:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My First Website</title> </head> <body> <h1>Hello, World!</h1> <p>This is my first website built with HTML and CSS.</p< </body> </html>
Let's look at what each part does:
<!DOCTYPE html>
: This tells the browser it's an HTML5 page.<html>
: This is the main part of the page. The lang
part says what language the page is in ("en" is for English).<head>
: This has info about the page, like the title and how to show it on phones.<meta charset="UTF-8">
: This lets the page show lots of different characters.<meta name="viewport" content="width=device-width, initial-scale=1.0">
: This makes the website look good on phones and tablets.<title>
: This is the title of the page. It shows in the browser tab. Good for people finding your site!<body>
: This has all the stuff people see on the page.<h1>
: This is a big heading. There are six heading sizes: <h1>
to <h6>
.<p>
: This makes a paragraph.Here are some other HTML tags you'll use a lot:
<a>
: This makes a link. Use href
to say where the link goes.<img>
: This shows a picture. Use src
to say where the picture is.<ul>
: This makes a list with bullets.<ol>
: This makes a numbered list.<li>
: This is one thing in a list.<div>
: This is a box you can put stuff in. It's good for organizing things.<span>
: This is like <div>
, but it's for things inside a line of text.<form>
: This makes a form where people can type things.<input>
: This is a place in a form where people can type (like a text box).<button>
: This makes a button you can click.<table>
: This makes a table.<tr>
: This is a row in a table.<th>
: This is a heading for a column in a table.<td>
: This is a cell in a table.<header>
: This is the top part of a page or section.<nav>
: This is for links that help you get around the site.<article>
: This is a piece of content that can stand on its own (like a blog post).<aside>
: This is content that's related to the page, but not the main part (like a sidebar).<footer>
: This is the bottom part of a page or section.CSS makes your HTML look good. There are three ways to use CSS:
<style>
tag in the <head>
..css
file and link it to your HTML. (This is the best way!)For big projects, use an external CSS file. It keeps your HTML clean and lets you use the same styles on different pages.
Make a new file called style.css
. Put it in the same folder as your HTML file. Add this line to your HTML's <head>
to link the CSS file:
<link rel="stylesheet" href="style.css">
CSS rules have a selector and a declaration block:
selector { property: value; }
p
, h1
, div
).{}
.color
, font-size
, margin
).red
, 16px
, 10px
).Here are some CSS examples:
p { color: blue; font-size: 14px; } h1 { color: green; text-align: center; } .highlight { background-color: yellow; } #main-content { width: 80%; margin: 0 auto; }
CSS selectors pick which HTML things to style. There are different kinds:
p
, h1
, div
)..highlight
). Class selectors start with a dot (.
).#main-content
). ID selectors start with a hash (#
). Each ID should only be used once on a page![type="text"]
).:hover
when the mouse is over it, or :active
when you click it).::before
or ::after
).Here are some CSS properties you'll use a lot:
color
: This sets the text color.font-size
: This sets the text size.font-family
: This sets the font.background-color
: This sets the background color.width
: This sets how wide something is.height
: This sets how tall something is.margin
: This sets the space around something.padding
: This sets the space inside something.border
: This puts a border around something.text-align
: This lines up the text.display
: This says how something should be shown (like block
, inline
, inline-block
, flex
, grid
).position
: This says where something should be placed (like static
, relative
, absolute
, fixed
, sticky
).Let's make a simple webpage to show how it all works. Here's the HTML code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Simple Website</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <h1>Welcome to My Website</h1> <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Services</a></li> <li><a href="#">Contact</a></li> </ul> </nav> </header> <main> <article> <h2>About Me</h2> <p>This is a simple website built with HTML and CSS. I am learning web development and this is my first project.</p> <img src="placeholder-image.jpg" alt="Placeholder Image" width="300"> </article> <aside> <h3>Recent Posts</h3> <ul> <li><a href="#">Post 1</a></li> <li><a href="#">Post 2</a></li> <li><a href="#">Post 3</a></li> </ul> </aside> </main> <footer> <p>© 2023 My Website</p> </footer> </body> </html>
And here's the CSS code (style.css
):
body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f0f0f0; } header { background-color: #333; color: white; padding: 20px; text-align: center; } nav ul { list-style: none; padding: 0; } nav li { display: inline; margin: 0 10px; } nav a { color: white; text-decoration: none; } main { display: flex; padding: 20px; } article { flex: 3; } aside { flex: 1; background-color: #ddd; padding: 10px; } footer { background-color: #333; color: white; text-align: center; padding: 10px; }
Save both files in the same folder. Then, open the HTML file in your browser. You should see a basic webpage. It has a header, links, main content, a sidebar, and a footer. Don't forget to replace "placeholder-image.jpg" with a real picture!
Great job! You've started your web development journey. Want to learn more? Try these:
Building a website with HTML CSS is a key skill. Keep practicing, and you can make awesome websites. Keep learning and keep building!
This guide showed you how to make a website with HTML CSS. Keep trying different tags, styles, and layouts. Have fun coding!
Learn how to responsive web design with CSS media queries & mobile-friendly techniques. Create websites that adapt seamlessly to all devices. Expert guide!
Learn how to HTML! This easy guide teaches you to build a simple website from scratch. Perfect for beginners in web development and coding tutorials.
Learn how to write Python code effectively. This guide covers Python programming basics, coding best practices, and computer science fundamentals. Start coding now!
Learn how to use version control (e.g., Git) for efficient software development. Collaborate effectively & manage code changes seamlessly. Start coding smarter!
Learn how to build a web development portfolio that showcases your skills & lands you jobs. Get expert tips & examples to create a winning portfolio!
Learn how to create a custom WordPress theme for a specific niche. Master web development & theme development for unique website design.
Learn how to create a secure Password Safe Chrome Extension using Web Development, Javascript, and optionally Python for backend integration.
Learn CSS quickly and effectively! This guide covers everything from the basics to advanced techniques. Perfect for web development & design. Start coding now!
Learn how to use Flask for Python web development. This tutorial covers setup, routing, templates, databases, & more! Build your first web app now!
Master Lua programming! This comprehensive guide covers Lua basics, scripting for game development, and advanced techniques. Start coding today!
Learn how to build an app from scratch! This guide covers app development basics, coding options, and tips for creating your first mobile app.
Learn how to build a Web API from scratch! This guide covers API development, backend basics, RESTful APIs, & coding best practices. Start your API journey now!