How to Create a Website using HTML and CSS | BrowserStack (2024)

Every developer on their journey to be a master web developer learns HTML in the first place. After being handy with HTML, one proceeds to the next step of learning, which is CSS. The modern-day webpages are so robust and made of advanced technology. Therefore, the question here is – Is HTML and CSS enough to create a website?

The short answer here is Yes.

For a static website that displays text, images, links, and buttons beautifully, HTML and CSS are more than enough to get you a good-looking landing page or even a business website. Let’s start learning the core concepts of HTML and CSS, and at the end of this tutorial, you will be able to create a beautiful website by just using HTML and CSS.

Table of Contents

  • How to Set Up your CSS and HTML for Creating a Website
  • How to Create a Website using HTML And CSS
    • Step 1: Create a Layout
    • Step 2: Set up the boiler code
    • Step 3: Create major elements in the layout
    • Step 4: Create the HTML content
    • Step 5: Create CSS for the layout
    • Step 6: Create CSS to style individual elements
    • Step 7: Add background color and style
  • How to optimize HTML code for Website?
  • How to optimize CSS code for Website
  • How to test a Website on Real Devices with BrowserStack Live?
  • Conclusion
  • How to Set Up your CSS and HTML for Creating a Website

    Before starting our HTML and CSS website project, first let’s set the necessary folder and file structure according to how you are going to code the entire project. Let’s name our folder “build a website HTML”. Inside the folder, create a new “index.html” file and two folders named “CSS” and “images.” Create a “style.css” file inside the CSS folder and store all the necessary images required in the project inside the images folder.

    Read More: Handling Images in HTML and CSS

    The naming convention is not necessary. However, a well-designed folder structure helps in quick navigation between the HTML and CSS files.

    How to Create a Website using HTML and CSS | BrowserStack (1)

    How to Create a Website using HTML And CSS

    In this section, let’s create a full-fledged website using only HTML and CSS. Most of the users have a question today – Can you create a website just using HTML and CSS?

    It is quite possible to create a good-looking website with the help of only HTML and CSS. HTML stands for Hypertext markup language and provides the skeleton for our website. However, CSS (Cascading Style Sheet) allows the skeleton to be more good-looking. Let us use seven steps to create a good-looking website from scratch.

    Step 1: Create a Layout

    First create a basic structure of your website as a rough sketch. There are a lot of free online services that will help you design your website. Nonetheless, you must have a basic structure of the website ready.

    How to Create a Website using HTML and CSS | BrowserStack (2)

    Step 2: Set up the boiler code

    Create a new project folder and create an empty index.html file inside the folder. Here, add the boilerplate code to the HTML file.

    <!DOCTYPE html><html lang="en"><head><title>How to create a website using HTML and CSS</title><link rel="stylesheet" href="css/style.css"></head><body><h1>Test</h1></body></html>

    Before starting the actual content add some test content in your HTML file, and run it on the browser to test if the code is working fine.

    How to Create a Website using HTML and CSS | BrowserStack (3)

    Step 3: Create major elements in the layout

    Create section elements in the HTML file.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>How to create a website using HTML and CSS</title><link rel="stylesheet" href="css/style.css"></head><body><header></header><main><section id="intro"></section><section id="about"></section><section id="contact"></section></main><footer></footer></body></html>

    Read More: Browser compatibility with CSS Gradients

    Step 4: Create the HTML content

    In the previous step, you had created the elements in the layout. In this step, fill in the HTML content. Note that, in this example, let us fill the content with dummy text only.

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>How to create a website using HTML and CSS</title><link rel="stylesheet" href="css/style.css"></head><body><header><nav><ul><li><a href="#intro">Home</a></li><li><a href="#about">About</a></li><li><a href="#contact">Contact</a></li></ul></nav></header><main><section id="intro"><div class="Container"><img src="Images/doggo.jpg" alt="display picture of doggo"><h2>My name is Doggo</h2></div> </section><section id="about"><div class="container"><h1>About Me</h1><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint, similique?</p><ul><li>Btech Qualified</li><li>Software Engineer</li><li>GATE AIR 01</li></ul></div></section><section id="contact"><div class="container"><h1>Contact me</h1><p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nam, laudantium.</p><ul><li>Email ID</li><li>Insta ID</li><li>Facebook ID</li></ul></div></section></main><footer><p>© Copyright 2022 Doggo Co LTd.</p></footer></body></html>

    Now, if you reload the page, you are going to get an output something like this. You are now going to give this webpage some CSS in the next step to make it good-looking.

    How to Create a Website using HTML and CSS | BrowserStack (4)

    Step 5: Create CSS for the layout

    Before adding the depth in the CSS, let us first add some basic CSS to make our webpage look somewhat similar to the layout that we designed in the first step.

    Moreover, we linked our HTML file to a CSS file in the second step while writing our boilerplate code. Add the basic layout CSS in the linked CSS file. In this step, we are going to focus on height, width, padding, margin, and display of the sections and images, to make them adjustable according to the webpage.

    *{padding: 0;margin: 0;}header{height: 45px;}header nav ul{display: flex;margin-left: 80%;}header nav ul li{padding-left: 10%;}section{height: 100vh;border: 1px solid grey;display: flex;justify-content: center;align-items: center;}.Container{margin-top: 10%}.Container img{height: 300px;}.Container h2{margin-top: 3%;}footer {line-height: 40px;display: flex;justify-content: center;}

    Learn More: What are CSS Breakpoints and Media Query Breakpoints

    Step 6: Create CSS to style individual elements

    In this step let us style individual content. Let us focus on properties like font, border, colors, and more.

    *{padding: 0;margin: 0;}header{height: 45px;}header nav ul{display: flex;margin-left: 70%;list-style: none;}header nav ul li{padding-left: 10%;}header a{text-decoration: none;color: brown;}section{height: 100vh;border: 1px solid grey;display: flex;justify-content: center;align-items: center;}.Container img{height: 300px;border-radius: 50%;}.Container h2{margin-top: 2%;font-size: 3em;font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;}.Container p, ul{margin-top: 2%;font-size: 1.5rem;}footer {line-height: 40px;display: flex;justify-content: center;font-size: 1rem;}

    Step 7: Add background color and style

    In this step,let us add some finishing touches, and our website is ready. Let us add a background image and background colors to the sections.

    #intro {background-image: url(pinkbg.jpg);background-repeat: round;}#about{background-color: bisque;}#contact{background-color: blanchedalmond;}

    After completing the entire code of our website, it will look something like this. Note that you can add more CSS to make it further good-looking.

    How to Create a Website using HTML and CSS | BrowserStack (5)

    Talk to an Expert

    How to optimize HTML code for Website?

    View the Source Code of an HTML Document

    To view the source code of any webpage:

    • Navigate to the webpage
    • Right-click on the page
    • Select “view page source”

    Alternatively, you may use a keyboard shortcut CTRL + U or CMD + U to inspect the source code of any HTML document.

    The source code of an HTML document will look something like this.

    How to Create a Website using HTML and CSS | BrowserStack (6)

    Nest HTML Elements

    Nesting in HTML is to apply several HTML tags to a single content. In nesting, one element can be placed inside other elements. Another benefit of nesting in HTML includes improving the readability of your code for you and other developers.

    Nesting in HTML will look something like this.

    How to Create a Website using HTML and CSS | BrowserStack (7)

    How to optimize CSS code for Website

    Style Images with CSS

    In this section, let’s learn how to style images with CSS such as adding a border to an image, adjusting its dimensions, and further specific CSS to our images in the webpage. First, add an image element in the HTML file.

    <img src="doggo.jpg" alt="Image of Doggo">

    How to Create a Website using HTML and CSS | BrowserStack (8)

    Now, it’s time to add CSS to the image to make it look good.

    img{height: 300px;border-radius: 50%;border: 12px dotted rgb(255, 85, 0);}

    This CSS will apply to all the images of our HTML document.

    How to Create a Website using HTML and CSS | BrowserStack (9)

    Read More: How to position Text Over an Image using CSS

    Styling Classes With CSS

    Now, let’s see how to create classes with the help of CSS. here, we shall learn how to apply CSS rules only to the HTML elements that have specific classes. First, let’s create an HTML element that has some class, and then we shall apply CSS to the entire class. Applying CSS to the entire class will allow us to style all the elements that have the particular class.

    <img src="dog background.jpg" alt="" class="blueBorder"><h2 class="blueBorder">My name is Doggo</h2><p class="blueBorder">Lorem10</p>

    In this example, we took three different elements having the same class. Once we apply CSS to the class, it will be applied to all the elements belonging to the same class.

    .blueBorder{border: 12px solid blue;}

    To use the class as a selector while creating a CSS rule, we use the ‘.’ symbol before writing the class name in the CSS file.

    How to Create a Website using HTML and CSS | BrowserStack (10)

    Styling IDs with CSS

    Using IDs as selectors while creating CSS rules is similar to using classes as selectors. However, IDs are unique in the HTML document, and no two elements can carry the same IDs. IDs are generally applied to elements that are present only once in the HTML document, such as the navbar, logo, and more.

    <h2 id="BrowserStack">Using ID as a CSS selector</h2>

    Now, let’s create a CSS rule, using ID as a selector.

    #BrowserStack{font-size: 2rem;color: blueviolet;background-color: bisque;}

    How to Create a Website using HTML and CSS | BrowserStack (11)

    Creating Pseudo-classes With CSS

    Pseudo-classes are classes that are activated when certain keywords are added to a selector that specifies a certain state. For example, the pseudo-class :hover is used to change the state of the element when a user hovers the pointer over it.

    Let’s take an example when we hover over the previous image, it changes the border color of the image.

    img:hover{border: 12px dotted blue;}

    How to Create a Website using HTML and CSS | BrowserStack (12)

    Styling HTML <div> element with CSS

    The div tag is often used to specify the container for HTML elements. It can also be used to structure the layout of the webpage. Now, let’s understand how to style the div element and its children elements.

    div{background-color: bisque;border: 10px solid rgb(232, 69, 69);border-radius: 2%;height: 50vh;width: 50vh;}

    How to Create a Website using HTML and CSS | BrowserStack (13)

    How to adjust the Content, Padding, Border, & Margins of an HTML Element With CSS

    Before understanding how to adjust the content, padding, border, and margins of an HTML element, let’s understand the CSS box model. It is a box that wraps around every HTML element in the DOM.

    How to Create a Website using HTML and CSS | BrowserStack (14)

    • Content box: It is the space where the content of the HTML element appears, such as images, text, and more.
    • Padding: It is the transparent area around the content of the element.
    • Border: It is the box surrounding the padding box. By default, the value of the border for every HTML element is zero; however, increasing the border value increases the space between the padding and the margin box.
    • Margin: It is the transparent area outside the border box.

    Let’s take the example of the previous image to understand how to adjust these values.

    img{height: 300px;border-radius: 50%;border: 12px dotted rgb(255, 85, 0);padding: 10px 10px 20px 20px;margin: 20px 20px 15px 10px;}

    How to Create a Website using HTML and CSS | BrowserStack (16)

    How to test a Website on Real Devices with BrowserStack Live?

    BrowserStack allows you to test your website on different browser-device combinations and check if your website is working as expected under real user conditions. Here’s how you can test your website on Real Devices & Browsers using BrowserStack Live:

    Sign up for a free BrowserStack account

    • Step 1: Launch BrowserStack Live
    • Step 2: Select the Browser-OS-Device combination on which you want to test your website.

    How to Create a Website using HTML and CSS | BrowserStack (17)

    • Step 3: Enable local testing

    BrowserStack allows you test your local website. To enable BrowserStack local testing, start a session on BrowserStack Live and look for the green indicator on the ‘Local Testing’ icon in the toolbar tray.

    Read More: Overcoming Challenges of Local Testing

    If the icon is red, look for the BrowserStack local app, download it, and launch a live session from the toolbar.

    How to Create a Website using HTML and CSS | BrowserStack (18)

    How to Create a Website using HTML and CSS | BrowserStack (19)

    Read More: What is IP Whitelisting and How it Elevates Local Testing

    • Step 4: Run the test

    Now, the final step is to enter the local host URL of your website, and it will display your website on the Live Session.

    How to Create a Website using HTML and CSS | BrowserStack (20)

    Conclusion

    If you require a static website that displays text, images, links, and buttons beautifully, HTML and CSS are more than enough to create a good-looking landing page or even a business website. In this guide, you’ve learned the core concepts of HTML and CSS, which enable you to create a beautiful website by just using HTML and CSS.

    To ensure the website delivers the right user experience, it is essential that you test it on real devices and browsers. BrowserStack Live allows you to test the website under real user conditions for accurate test results.

    Try BrowserStack Live

    How to Create a Website using HTML and CSS | BrowserStack (2024)
    Top Articles
    Equipping Consumers with Digital Financial Literacy Skills | Capital One
    CosmWasm smart contracts | Cosmos SDK
    Maxtrack Live
    Trevor Goodwin Obituary St Cloud
    Cottonwood Vet Ottawa Ks
    Weeminuche Smoke Signal
    Pangphip Application
    Summit County Juvenile Court
    Kraziithegreat
    Craigslist Free Stuff Appleton Wisconsin
    Dark Souls 2 Soft Cap
    Dityship
    Nichole Monskey
    Shooting Games Multiplayer Unblocked
    Dumb Money
    Beau John Maloney Houston Tx
    Uc Santa Cruz Events
    Equipamentos Hospitalares Diversos (Lote 98)
    Puretalkusa.com/Amac
    Georgia Vehicle Registration Fees Calculator
    Schedule 360 Albertsons
    Faurot Field Virtual Seating Chart
    Zack Fairhurst Snapchat
    Marine Forecast Sandy Hook To Manasquan Inlet
    Valic Eremit
    What Individuals Need to Know When Raising Money for a Charitable Cause
    Amelia Chase Bank Murder
    Dove Cremation Services Topeka Ks
    Garden Grove Classlink
    Studentvue Calexico
    Xxn Abbreviation List 2023
    Rs3 Bring Leela To The Tomb
    Craigslist Cars And Trucks Mcallen
    Fbsm Greenville Sc
    Skroch Funeral Home
    Indiana Wesleyan Transcripts
    Covalen hiring Ai Annotator - Dutch , Finnish, Japanese , Polish , Swedish in Dublin, County Dublin, Ireland | LinkedIn
    KITCHENAID Tilt-Head Stand Mixer Set 4.8L (Blue) + Balmuda The Pot (White) 5KSM175PSEIC | 31.33% Off | Central Online
    That1Iggirl Mega
    Bitchinbubba Face
    Raising Canes Franchise Cost
    Fototour verlassener Fliegerhorst Schönwald [Lost Place Brandenburg]
    B.C. lightkeepers' jobs in jeopardy as coast guard plans to automate 2 stations
    Infinite Campus Farmingdale
    Let's co-sleep on it: How I became the mom I swore I'd never be
    Ezpawn Online Payment
    Anthem Bcbs Otc Catalog 2022
    Caesars Rewards Loyalty Program Review [Previously Total Rewards]
    Sapphire Pine Grove
    Bones And All Showtimes Near Emagine Canton
    Island Vibes Cafe Exeter Nh
    Latest Posts
    Article information

    Author: Rubie Ullrich

    Last Updated:

    Views: 6158

    Rating: 4.1 / 5 (72 voted)

    Reviews: 95% of readers found this page helpful

    Author information

    Name: Rubie Ullrich

    Birthday: 1998-02-02

    Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

    Phone: +2202978377583

    Job: Administration Engineer

    Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

    Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.