Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 272623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:20:15+00:00 2026-05-12T00:20:15+00:00

A form on my website’s contact -us HTML page has two fields 1) subject

  • 0

A form on my website’s contact -us HTML page has two fields

1) subject

2) message

When the page loads for the first time I want these two boxes to display messages like “Enter subject here” and “Enter Message here“.

I found that we can do this by using the “value” attribute of the text box, is this the best way ??..
What alternatives do I have to achieve this ?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:20:15+00:00Added an answer on May 12, 2026 at 12:20 am

    Oh, I really need to finish writing my article on this subject. Here’s the unpolished version:

    First — a message describing what to enter into a field is not a default value. Default values are things which could be conceivably submitted (such as a country being entered based on GeoIP, or a delivery address from customer records).

    Second — using the default value as a fake label and then wiping it when the user focuses it (presumably you don’t want the user to have to manually delete the message) causes accessibility problems. Screen readers read out the content that is focused, if you delete it when it becomes focused, they can’t get the information.

    The best option, in my opinion, is to place a <label> next to the control. Webpages aren’t typically short on space — scrollbars are not evil.

    If you really want it to look like it is in the control then:

    1. Put the <label> and <input> in a <div>
    2. Set a class on that <div> using JavaScript (so you don’t have a crap experience is JS isn’t available)
    3. Apply CSS to set the <div> to position: relative and give it a size.
    4. Make the background of the <input> transparent and style it to fill the div
    5. Position the <label> under the <input>
    6. Write a function that checks to see if the value of the input is an empty string or not. Toggle a class on the div on and off depending on the answer.
    7. When that class is set on the div, set text-indent to a high negative length (such as -999em) so that the text is hidden off screen (but still available to screen readers)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML form on my website. The form has various fields and
I have a comment form on my website on contact.aspx . I want to
I have a form on a website which has a lot of different fields.
I have this contact form on my website, the things i want to do
I am building a website form in HTML that I want to gather information
I have a contact form on my website so users can send me an
I have a login form for my website. This login form have two text
I have a PHP contact form on my website. I have been using it
I'm building a simple contact form for a website. It does not connect to
I have a html form on DNN website. This form will submit data to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.