What are the best practices for structuring HTML elements like input and label tags in PHP forms?

When structuring HTML elements like input and label tags in PHP forms, it is important to properly associate labels with their corresponding input fields for accessibility and usability purposes. This can be achieved by using the "for" attribute in the label tag that matches the "id" attribute of the input field. Additionally, organizing the form elements in a logical and semantic way can improve the overall user experience.

<form action="submit.php" method="post">
    <label for="username">Username:</label>
    <input type="text" id="username" name="username">
    
    <label for="password">Password:</label>
    <input type="password" id="password" name="password">
    
    <label for="email">Email:</label>
    <input type="email" id="email" name="email">
    
    <input type="submit" value="Submit">
</form>