Skip to content
TheChatArchiveThe Chat Archive
gpt-4-1106-preview· OpenAIHugging Face Arena Human Preference 55K

create a html code for contact form and style it using tailwindcss

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-3.5-turbo-1106’s answer.
  1. User

    create a html code for contact form and style it using tailwindcss

  2. Assistant

    Certainly! Below is a basic example of an HTML code for a contact form styled with Tailwind CSS. It includes input fields for name, email, and message, as well as a submit button.

    First, make sure you have Tailwind CSS included in your project. You can include it via CDN in your HTML file's <head> section:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Contact Form</title>
        <!-- Include Tailwind CSS via CDN -->
        <script src="https://cdn.tailwindcss.com"></script>
    </head>
    <body>
        <div class="flex justify-center items-center h-screen bg-gray-100">
            <form class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
                <div class="mb-4">
                    <label class="block text-gray-700 text-sm font-bold mb-2" for="name">
                        Name
                    </label>
                    <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="name" type="text" placeholder="Your name">
                </div>
                <div class="mb-4">
                    <label class="block text-gray-700 text-sm font-bold mb-2" for="email">
                        Email
                    </label>
                    <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline" id="email" type="email" placeholder="you@example.com">
                </div>
                <div class="mb-6">
                    <label class="block text-gray-700 text-sm font-bold mb-2" for="message">
                        Message
                    </label>
                    <textarea class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline" id="message" placeholder="Your message" rows="4"></textarea>
                </div>
                <div class="flex items-center justify-between">
                    <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" type="submit">
                        Send
                    </button>
                </div>
            </form>
        </div>
    </body>
    </html>
    

    In this code:

    • The <form> element is styled with a white background, a shadow, rounded corners, and padding.
    • Each label/input pair is wrapped in a <div> with a mb-4 class to ensure margin-bottom spacing.
    • Labels have a text color of text-gray-700, are text-sm in size, and are font-bold.
    • Input fields have a shadow, rounded corners, and full width with padding, with focus styles to highlight when active.
    • The submit button has a blue background, which darkens on hover, white text, bold font, and rounded corners.

    Remember to replace the action attribute in the <form> tag with the URL where you want to send the form data when submitted. Since we are using the Tailwind CSS CDN, you can directly use the utility classes without any additional setup. However, in a production environment, you should install Tailwind CSS via npm or yarn to customize the configuration and optimize the final build.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.