DeveloperBreeze

Html Programming Tutorials, Guides & Best Practices

Explore 5+ expertly crafted html tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Tutorial
php

Creating a Countdown Timer with JavaScript

  • Basic knowledge of HTML, CSS, and JavaScript.
  • A text editor to write the code.
  • A browser to view the output.

We will create a countdown timer that counts down to the 20th of the next month. If the current date is the 20th or later, it will count down to the 20th of the month after next. The countdown will stop once the deadline is reached.

Oct 24, 2024
Read More
Tutorial
php

Exporting Table Row Data to CSV in JavaScript

// Select all export buttons
const exportButtons = document.querySelectorAll('.export-btn');

// Add event listener to each export button
exportButtons.forEach(button => {
    button.addEventListener('click', () => {
        // Get the parent row of the clicked button
        const row = button.closest('tr');

        // Get all cells in the row except the last one (which contains the export button)
        const cells = Array.from(row.querySelectorAll('td'));
        cells.pop(); // Remove the last cell (the button cell)

        // Extract the text content of each cell and wrap them in double quotes (CSV format)
        const cellValues = cells.map(cell => `"${cell.textContent}"`);

        // Create the CSV data by joining cell values with commas
        const csvData = cellValues.join(',');

        // Create a temporary anchor element for the download
        const anchor = document.createElement('a');
        anchor.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csvData);
        anchor.download = 'row_data.csv';

        // Programmatically click the anchor to trigger the download
        anchor.click();
    });
});
  • querySelectorAll('.export-btn'): Selects all elements with the class export-btn, i.e., the export buttons.
  • closest('tr'): This retrieves the closest table row (<tr>) that contains the clicked button.
  • querySelectorAll('td'): Retrieves all the <td> cells in the row.
  • Array.from(): Converts the list of cells into an array, which allows us to manipulate it easily.
  • cells.pop(): Removes the last cell (the one containing the export button), as we don’t want it in the CSV.
  • textContent: Extracts the text content from each cell.
  • encodeURIComponent(): Encodes the CSV string, making it safe for use in a URL.
  • anchor.download: Specifies the filename for the CSV file (in this case, row_data.csv).
  • anchor.click(): Programmatically triggers a click on the anchor element, which starts the download.

Oct 24, 2024
Read More
Tutorial
javascript css +1

دليل شامل لتطوير الويب: بناء موقع بسيط باستخدام HTML, CSS وJavaScript

<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>موقعي الشخصي</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <header>
        <h1>مرحباً بكم في موقعي</h1>
        <nav>
            <ul>
                <li><a href="#home">الرئيسية</a></li>
                <li><a href="#about">من أنا</a></li>
                <li><a href="#contact">تواصل معي</a></li>
            </ul>
        </nav>
    </header>

    <section id="home">
        <h2>مقدمة</h2>
        <p>هذا هو موقعي الشخصي حيث أشارك فيه أفكاري ومشاريعي.</p>
    </section>

    <section id="about">
        <h2>من أنا</h2>
        <p>أنا مطور ويب مهتم بتقنيات الويب الحديثة وتطوير التطبيقات.</p>
    </section>

    <section id="contact">
        <h2>تواصل معي</h2>
        <form id="contact-form">
            <label for="name">الاسم:</label>
            <input type="text" id="name" name="name" required>

            <label for="email">البريد الإلكتروني:</label>
            <input type="email" id="email" name="email" required>

            <label for="message">رسالتك:</label>
            <textarea id="message" name="message" required></textarea>

            <button type="submit">إرسال</button>
        </form>
    </section>

    <footer>
        <p>© 2024 جميع الحقوق محفوظة</p>
    </footer>

    <script src="scripts.js"></script>
</body>
</html>
  • يحتوي هذا الملف على الهيكل الأساسي لصفحة الويب. يبدأ بـ <!DOCTYPE html> والذي يعرّف نوع المستند.
  • داخل الـ<head> قمنا بتضمين معلومات مثل ترميز الصفحة (UTF-8) والعنوان (<title>).
  • يحتوي <body> على الأقسام المختلفة للموقع مثل العنوان (header)، الأقسام المختلفة (section) وfooter.
  • استخدمنا أيضًا عنصر <form> لإدخال بيانات الزوار.

Sep 27, 2024
Read More
Cheatsheet
html

HTML5 Cheatsheet

  • text: Single-line text input.
  • email: Validated email address.
  • password: Password input (masked).
  • number: Numeric input.
  • date: Date picker.
  • radio: Single-choice options.
  • checkbox: Multiple-choice options.
  • file: File upload.

HTML5 introduces semantic elements to improve document structure and accessibility:

Aug 03, 2024
Read More