Friday, March 29, 2024

A basic html with css and javascript for scratch web devs


 

Hey there assassins long time after we created a post about html a basic relevant post was frii classes

now we will introduce a professional skeleton html css and js based code that will help us to understand 

the html language better\


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>Professional Website</title>

    <link rel="stylesheet" href="style.css">

</head>

<body>

    <header>

        <h1>Welcome to our Professional Website</h1>

    </header>

    <nav>

        <ul>

            <li><a href="#home">Home</a></li>

            <li><a href="#about">About</a></li>

            <li><a href="#services">Services</a></li>

            <li><a href="#contact">Contact</a></li>

        </ul>

    </nav>

    <section id="home" class="section">

        <h2>Welcome</h2>

        <p>This is a professional website built to showcase our services.</p>

    </section>

    <section id="about" class="section">

        <h2>About Us</h2>

        <p>We are a team of professionals dedicated to providing high-quality services to our clients.</p>

    </section>

    <section id="services" class="section">

        <h2>Our Services</h2>

        <ul>

            <li>Web Design</li>

            <li>Graphic Design</li>

            <li>Digital Marketing</li>

            <li>Content Writing</li>

        </ul>

    </section>

    <section id="contact" class="section">

        <h2>Contact Us</h2>

        <p>Feel free to reach out to us for any inquiries or collaborations.</p>

        <form>

            <label for="name">Name:</label><br>

            <input type="text" id="name" name="name"><br>

            <label for="email">Email:</label><br>

            <input type="email" id="email" name="email"><br>

            <label for="message">Message:</label><br>

            <textarea id="message" name="message" rows="4"></textarea><br>

            <input type="submit" value="Submit">

        </form>

    </section>

    <footer>

        <p>&copy; 2024 Professional Website. All rights reserved.</p>

    </footer>

    <script src="script.js"></script>

</body>

</html>



the additional css code/


/* Reset default browser styles */
body, h1, h2, h3, p, ul, li, form, input, textarea {
    margin: 0;
    padding: 0;
}

/* Basic styling */
body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

header {
    background: #333;
    color: #fff;
    padding: 20px;
    text-align: center;
}

nav {
    background: #444;
    padding: 10px;
}

nav ul {
    list-style: none;
    text-align: center;
}

nav ul li {
    display: inline;
    margin-right: 20px;
}

nav ul li a {
    color: #fff;
    text-decoration: none;
}

.section {
    padding: 20px;
}

footer {
    background: #333;
    color: #fff;
    text-align: center;
    padding: 10px;
    position: fixed;
    bottom: 0;
    width: 100%;
}

/* Additional styling */
h2 {
    color: #333;
}

section {
    background: #f4f4f4;
    margin: 20px;
    border-radius: 5px;
}

ul {
    list-style: disc;
    margin-left: 20px;
}

form {
    margin-top: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
textarea {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

input[type="submit"] {
    background: #333;
    color: #fff;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px;
}

input[type="submit"]:hover {
    background: #444;
}


the js code/

document.addEventListener("DOMContentLoaded", function() {
    // Smooth scrolling for navigation links
    const navLinks = document.querySelectorAll('nav ul li a');

    navLinks.forEach(link => {
        link.addEventListener('click', smoothScroll);
    });

    function smoothScroll(e) {
        e.preventDefault();

        const targetId = e.target.getAttribute('href').substring(1);
        const targetSection = document.getElementById(targetId);
        
        window.scrollTo({
            top: targetSection.offsetTop,
            behavior: 'smooth'
        });
    }

    // Form submission handling
    const form = document.querySelector('form');

    form.addEventListener('submit', function(e) {
        e.preventDefault();

        const formData = new FormData(this);
        const formDataObject = {};
        
        formData.forEach((value, key) => {
            formDataObject[key] = value;
        });

        // Here you can do whatever you want with the form data
        // For example, send it to a server or display it
        // Here, we're just displaying it in an alert
        alert("Form submitted!\n\nName: " + formDataObject.name + "\nEmail: " + formDataObject.email + "\nMessage: " + formDataObject.message);
        
        // Clear form fields
        this.reset();
    });
});


and these credit goes to chatgpt lol :))

0 comments:

Post a Comment

Contact Us

Phone :

+8801716815647
+8801996204467
+8801520731186

Email :

susmoy1025@gmail.com
dishantanjim@gmail.com
sadmansakib7494@gmail.com