top of page

Want to generate your own video summary in seconds?

How to Create a Functional Contact Form with HTML and CSS

Learn how to create a functional contact form using HTML and CSS in this step-by-step tutorial. Discover styling techniques, responsive design, and Web3 Forms integration.

Video Summary

Creating a functional contact form using HTML and CSS can be a straightforward process, as demonstrated in this comprehensive tutorial. The presenter begins by establishing a project folder named 'contact form' and opening it in the popular code editor, Visual Studio Code (VS Code). This initial setup is crucial for organizing the files needed for the project. Within this folder, the presenter creates two essential files: 'index.html' for the HTML structure and 'style.css' for the styling, ensuring that the CSS is properly linked to the HTML document.

The contact form is designed to collect user information, including fields for the user's name, email, and message, all of which are mandatory for submission. After laying out the HTML structure, the presenter utilizes the Live Server extension to run the HTML file in a web browser, allowing for real-time viewing of changes. The form layout features a left column dedicated to input fields and a right column showcasing an image, creating a visually appealing design.

To enhance the form's appearance, CSS styles are applied, including a striking linear gradient background and a flexbox layout for optimal alignment. The tutorial emphasizes the simplicity of creating a working contact form, guiding viewers through each step to ensure they can replicate the process with ease. Key styling steps include:

1. **Styling the Title**: The font size is set to a prominent 40 pixels, accompanied by a margin-bottom of 5 pixels to create space below the title.

2. **Horizontal Line (HR Tag)**: This element is styled with a width of 120 pixels, a height of 5 pixels, a background color, and a border radius of 10 pixels, adding a polished look to the form.

3. **Input Fields**: Each input field is assigned the class 'contact inputs', with dimensions of 400 pixels in width and 50 pixels in height, along with specific border properties to enhance usability.

4. **Text Area**: The height of the text area is increased to 140 pixels, while the border radius is reduced to 20 pixels for a more modern appearance.

5. **Focus Effect**: A border effect is introduced when input fields are focused, providing visual feedback to users.

6. **Placeholder Text**: This text is styled in a light gray color, ensuring it is visible yet subtle.

7. **Submit Button**: The button is configured with a flex display, appropriate padding, a readable font size, a contrasting color, a border radius, and a linear gradient background that makes it stand out.

8. **Image on Right Side**: The image is set to a width of 500 pixels, complementing the overall design of the form.

9. **Responsive Design**: Media queries are implemented to adjust the input field width to 80% on screens smaller than 800 pixels, and the right-side image is hidden on mobile views to enhance usability on smaller devices.

10. **Web3 Forms Integration**: To enable functionality, an access key is created by providing an email on web3forms.com. This key is then integrated into the HTML form's action attribute, allowing for seamless form submissions.

After completing the setup, a test submission is conducted using the name 'Elon Musk', the email 'el123@gmail.com', and the message 'launching rocket'. This test confirms the successful submission of the form and the receipt of an email notification, showcasing the effectiveness of the contact form.

The tutorial concludes with an invitation for viewers to ask questions and subscribe for more insightful content, encouraging engagement and further learning opportunities.

Click on any timestamp in the keypoints section to jump directly to that moment in the video. Enhance your viewing experience with seamless navigation. Enjoy!

Keypoints

00:00:00

Introduction

The video begins with a welcome message, introducing the tutorial on creating a contact form using HTML and CSS. The form will allow users to enter their contact information and receive inquiries via email.

00:00:30

Form Submission

The speaker demonstrates the functionality of the contact form by filling in a name, email ID, and message, followed by a successful submission notification. The inquiry is then shown to be received in the Gmail inbox, confirming the form's operational status.

00:01:03

Project Setup

The tutorial proceeds with setting up the project by creating a folder named 'contact form' and opening it in Visual Studio Code. The speaker emphasizes the use of any code editor for this task.

00:01:30

HTML Structure

An HTML file named 'index.html' is created, and the basic document structure is established. The title of the document is set to 'contact form', and a CSS file named 'style.css' is linked to the HTML file to style the form.

00:02:05

Assets Management

The speaker copies an 'assets' folder containing images into the project folder. This folder includes two images, 'Arrow icon' and 'write IMG', which will be used in the contact form.

00:02:33

Live Server Setup

To view the HTML file, the speaker installs and uses the Live Server extension in Visual Studio Code. The HTML file is opened in a web browser to facilitate real-time updates during development.

00:02:50

Form Layout

The speaker begins constructing the contact form's layout within the body tag of the HTML file. A div with the class 'contact container' is created, which will house two columns: one for the form and another for additional content.

00:03:25

Input Fields

In the left column of the form, the speaker adds input fields. The first input field is designated for the user's name, with the type set to 'text' and a placeholder text 'your name' to guide users on what to enter.

00:04:23

Input Fields Setup

The speaker begins by adding input fields to a form, specifying the type as 'text' for the first field, which includes a placeholder for 'your name' and a class name 'contact inputs'. They make this field mandatory by adding the 'required' attribute. Next, they duplicate this input field, changing the type to 'email', updating the name to 'email', and the placeholder to 'your email', while keeping the class name the same.

00:05:00

Message Box Creation

The speaker proceeds to create a message box by adding a text area. They name this field 'message', remove unnecessary ID columns and rows, and set a placeholder to 'your message'. This field also adopts the 'contact inputs' class and is marked as required, ensuring all three input fields must be filled out to submit the form.

00:05:27

Button and Image Tag Addition

A button tag is created with the type set to 'submit' and the button text labeled 'submit'. Additionally, an image tag is included, pointing to the file path 'assets/SLAro/icon.png'. After saving these changes, the speaker returns to the web page to confirm the visibility of the input fields and the submit button.

00:05:55

Image Integration

In the right div of the layout, the speaker adds another image tag, specifying the file path as 'assets/right_img.png'. This addition is confirmed by checking the web page, where the image appears as intended.

00:06:14

CSS Properties for HTML Elements

The speaker shifts focus to styling, starting with global CSS properties. They apply a global selector to set padding and margin to zero and box-sizing to 'border-box'. Following this, they style the body tag by setting the font family to 'Outfit' and applying a linear gradient background color using two specified color codes.

00:07:01

Contact Container Styling

The speaker adds CSS properties for the 'contact container' class, setting its height to 100 VH and using 'display: flex' to arrange columns on the left and right. They also align items to the center and justify content evenly, which is confirmed by checking the web page where the input fields are displayed on the left and the image on the right.

00:07:28

Left Column CSS Adjustments

Further CSS adjustments are made for the 'contact left' class, where the speaker sets the display to 'flex', the flex direction to 'column', aligns items to the start, and introduces a gap of 20 pixels between elements. This results in a vertical alignment of all contents in the left column.

00:07:58

Title Styling

The speaker styles the title within the 'contact left title' div, targeting the h2 tag. They set the font weight to 600, change the color, increase the font size to 40 pixels, and add a margin-bottom of 5 pixels, enhancing the title's appearance.

00:08:30

Horizontal Line Styling

Finally, the speaker styles the horizontal line (HR tag) within the 'contact left title' class. They remove the border, set the width to 120 pixels, and the height to 5 pixels, completing the visual adjustments for the contact form.

00:08:48

Background Styling

The speaker discusses adding a background color code, setting a border radius of 10 pixels, and applying a bottom margin of 20 pixels to enhance the visual appeal of the horizontal line.

00:09:11

Input Field Design

For the input fields, the speaker specifies the class name 'contact inputs' applicable to all three fields. They set the width to 400 pixels, height to 50 pixels, and remove borders and outlines. Additionally, they add 25 pixels of left padding, a font weight of 500, and a gray color, concluding with a border radius of 50 pixels.

00:09:56

Text Area Adjustment

The speaker increases the height of the text area to 140 pixels, adds top padding, and reduces the border radius to 20 pixels, resulting in an improved appearance for the message box.

00:10:21

Input Focus Effect

To enhance user interaction, the speaker adds a focus effect to the input fields, specifying a 2-pixel solid border with a designated color code that appears when any input field is clicked.

00:10:47

Placeholder Styling

The speaker styles the placeholder text by applying a light gray color code, ensuring that the placeholder text is visually appealing and consistent with the overall design.

00:11:11

Submit Button Design

The speaker outlines the CSS properties for the submit button, including a flex display for horizontal alignment of text and icon, padding of 15 pixels top and bottom and 30 pixels left and right, a font size of 16 pixels, and a white text color. They also specify a gap of 10 pixels, remove borders, set a border radius of 50 pixels, and apply a linear gradient background with two color codes at a 270° angle, concluding with a cursor pointer effect.

00:12:16

Arrow Icon Adjustment

The speaker reduces the size of the arrow icon within the button by setting its height to 15 pixels, achieving a visually balanced design.

00:12:35

Right Side Image Styling

For the right side of the layout, the speaker applies the class name 'contact right' to the image, setting its width to 500 pixels to ensure it fits well within the screen.

00:12:56

Responsive Design Check

The speaker inspects the webpage on smaller screens, noting the need for adjustments due to spacing issues between the left and right columns. They plan to implement CSS media queries with a max width of 800 pixels to address these layout concerns.

00:13:24

Contact Form Design

The speaker discusses modifying the contact form's design by changing the width to 80 viewport width. They remove an image from the mobile view by adding 'display: none' to ensure only the contact form is visible on smaller screens, while the desktop view retains the right-side image. The design for the contact form is now complete.

00:14:04

Form Functionality Setup

To make the contact form functional, the speaker plans to use Web3 Forms. They navigate to web3forms.com, create an access key by entering their email address, and receive a confirmation email with the public access key. The speaker then updates the HTML file by replacing the action link with the one provided by Web3 Forms and adds the necessary input fields, including the access key.

00:15:29

Testing Contact Form

After setting up the contact form, the speaker refreshes the website and tests the form by entering a name (Elon Musk), a dummy email (el123@gmail.com), and a message ('launching rocket'). Upon clicking the submit button, they confirm that the form submits successfully, and a notification appears in their Gmail with the entered details, demonstrating that the contact form is working as intended.

00:16:24

Conclusion and Engagement

The speaker concludes the video by expressing hope that the tutorial is helpful. They encourage viewers to ask questions in the comment section, like and share the video, and subscribe to their channel, 'greatest attack,' for more content.

Did you like this Youtube video summary? 🚀

Try it for FREE!

bottom of page