<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <title>Data Copy</title>
    <label for="firstName">First Name:</label>
    <input type="text" id="firstName" name="firstName"><br><br>
    <label for="lastName">Last Name:</label>
    <input type="text" id="lastName" name="lastName"><br><br>
    <label for="email">Email:</label>
    <input type="email" id="email" name="email"><br><br>
    <button type="button" onclick="copyData()">Copy Data</button>


  body {
      font-family: Arial, sans-serif;
      margin: 20px;

    form {
      width: 300px;
      margin: 0 auto;

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

    button {
      width: 100%;
      padding: 8px;
      margin-bottom: 15px;
      box-sizing: border-box;

    button {
      background-color: #007bff;
      color: #fff;
      border: none;
      cursor: pointer;

    button:hover {
      background-color: #0056b3;


    function copyData() {
      // Get input field values
      var firstName = document.getElementById('firstName').value;
      var lastName = document.getElementById('lastName').value;
      var email = document.getElementById('email').value;
      // Create a string with the collected data
      var copiedData = "First Name: " + firstName + "\n" +
                       "Last Name: " + lastName + "\n" +
                       "Email: " + email;
      // Copy the data to the clipboard
        .then(function() {
          alert('Data copied successfully!');
        .catch(function(err) {
          console.error('Failed to copy: ', err);

Try to answer about this code:

What does the navigator.clipboard.writeText() method do in the provided code?

It writes the text to a local file.
It writes the text to the clipboard.

It reads the clipboard content.
It clears the clipboard content.

Which attribute of the <input> tag in the form is used to specify that the input field is read-only?



What does the box-sizing: border-box; property do in the CSS part of the code?

It adds a border to the box.
It includes the border and padding in the element's total width and height.

It removes the border from the box.
It increases the box's width and height by the border size.

Which tag is used to define a script within an HTML document?