In this tutorial, you will create a simple web interface using HTML and CSS that displays the status of a plant. This interface will show sensor data such as soil moisture levels, water tank levels, and will include buttons to control different actions like watering the plant.
This project will serve as a basic template for you to customize and expand. You can add more features, change the design, or adjust it to fit your specific project needs. Whether you're building a real monitoring system or just practicing your web development skills, this template will help you get started.
Here's an image of what the finished plant status panel will look like:
Follow the steps below to begin building your own plant status panel!
Create a folder called plant_monitoring_panel. Inside the folder, create two files:
Explanation: The index.html file will contain the structure of the webpage. This is the framework that browsers use to display content.
The style.css file will contain rules that define how the webpage looks (colors, fonts, positioning, etc.). You’ll link the two together in the next steps.
Copy-paste location: Create these two empty files inside the plant_monitoring_panel folder on your computer.
Explanation:
<!DOCTYPE html> tells the browser you’re using the latest version of HTML5.<html lang="en"> defines the document as an HTML file and sets the language to English for accessibility and SEO.<head> section holds metadata like the character set (UTF-8) and the link to the external stylesheet (style.css).<body> contains all the visible content of the page.<header> tag is used to define the header area of the page, with an <h1> heading that displays "Plant Monitoring Dashboard."
Copy-paste location: Paste this code into the index.html file you created earlier.
Explanation:
<section> groups content into logical sections, in this case for the plant’s status.<h2> creates a secondary heading for this section.<p> creates paragraphs for each sensor reading (e.g., soil moisture and water tank levels).<span> tags wrap the dynamic sensor values, allowing you to update them with JavaScript later.
Copy-paste location: Paste this code into the index.html file, right after the closing </header> tag.
Explanation:
<div> is used to group the buttons together.<button> creates interactive buttons that can trigger actions, such as watering the plant or increasing humidity.
Copy-paste location: Paste this code into the index.html file, just before the </section> tag.
Explanation:
<img> is used to display an image. The src attribute specifies the image file's location.alt attribute provides alternative text for screen readers or in case the image fails to load.id allows you to style or manipulate the image later using CSS or JavaScript.
Copy-paste location: Paste this code into the index.html file, after the closing </div> tag (right after the control buttons).
Explanation:
* { margin: 0; padding: 0; } resets default browser styles for padding and margins, making sure that all elements start from a consistent baseline.box-sizing: border-box; ensures that padding and borders are included in the element’s total width and height.body styles the entire page with a light background color, default text color, and applies a padding to the page content.
Copy-paste location: Paste this code into the style.css file you created earlier.
Explanation:
background-color sets the background color of the header to green (#4CAF50).color changes the text color to white.padding adds space around the text within the header.text-align: center; centers the text horizontally within the header.margin-bottom adds space below the header to separate it from other sections.border-radius rounds the corners of the header for a softer look.
Copy-paste location: Paste this code into the style.css file, after the body styling.
Explanation:
.plant-status adds a white background, padding, and a border around the sensor readout section.max-width: 400px; ensures that the section doesn’t get too wide, even on large screens.margin: 0 auto; centers the section horizontally on the page.text-align: center; centers the text inside this section.h2 adjusts the heading size and adds space below it.p adjusts the spacing and size of the sensor readout paragraphs.span makes the sensor values bold to stand out.
Copy-paste location: Paste this code into the style.css file, after the header styling.
Explanation:
background-color gives the buttons the same green color as the header.color changes the text on the buttons to white.padding adds space inside the buttons to make them easier to click.margin adds space between each button.cursor: pointer; makes the mouse pointer change to a hand icon when hovering over the buttons, indicating that they are clickable.border-radius gives the buttons rounded corners.hover changes the background color when the user hovers over the button, providing visual feedback.
Copy-paste location: Paste this code into the style.css file, after the plant status section styling.
Explanation:
margin-top adds space above the image to separate it from the buttons.width limits the image to a fixed width of 200px.border-radius adds rounded corners to the image for a polished look.
Copy-paste location: Paste this code into the style.css file, after the button styling.