How to display the value of the bar on each bar
More examples: https://i.sstatic.net/eIAI7.png
Is adding a question mark at the end of the sentence compulsory, optional or incorrect?
How to display the value of the bar on each bar
More examples: https://i.sstatic.net/eIAI7.png
Is adding a question mark at the end of the sentence compulsory, optional or incorrect?
That is not a question, it is not even a sentence.
It is a fragment. You could use it make a statement:
I will show you [how to display the value...].
The fragment is an interrogative content clause, that functions as the second object of "show" in the example. The statement here ends with a full stop, since it isn't a question.
In headlines and title, fragments can be used. The meaning is "This document is about [how to display...]" You would not normally use any punctuation at the end of titles. For example if you a chapter about "Cats" your chapter title could be "Cats", and you would not put a question mark or a full stop. There is no requirement for title headings to be complete sentences.
If a title is actually a question then a question mark is appropriate. So if your title is "What Are Cats?" you would end with a question mark.
How to display the value of the bar on each bar[?]
First, the answer for ELL:
Don't use "How to" when asking questions. It is considered 'incorrect', a sentence fragment, or an elision, rather than a complete sentence.
Even if, for some reason, you must use it, then if it's a question, it needs a question mark at the end. So, you might have titled this question "How to punctuate a 'how-to' question fragment?"
Without the "?", there is ambiguity: the reader doesn't know if you are asking how to do it, or explaining how to do it.
These are questions, so they have '?' appended, whereas:
...is intended as a guide, not a question, so it has a '.' at the end instead.
Even if you get it wrong, people will understand from context, but it's better to get it right in the first place, something like:
Or, to rephrase the quoted question:
Advanced usage (as a sentence fragment):
For English Language Learners, it is best if you just do not use this format at all. You will be understood, but it will sound "weird".
What follows is more appropriate for the "English Language and Usage" Stack Exchange site, and should not be taken as guidance for learners!
I suspected that I might find this format used in a Sherlock Holmes story, from the late 1880s, and indeed I did. That I can tell, Sir Arthur Conan Doyle used this exact format only once in all of his stories, in 'The Adventure of the Blue Carbuncle', 1892:
"He would show me how to turn the stone into money. But how to get to him in safety?"
This was spoken by a character in the story; his use of the elided sentence fragment marks him as a less-learned, less precisely-spoken person; and indeed the character is a criminal.
You can see that here it's a question, so has the "?" question mark.
There's also a similar and far more common phrase used several times in his works, which reduces this question to its barest parts: 'where to', as in 'The Sign of the Four', 1890:
"Where to?" asked Jones.
This is very clearly an elision, the missing words meaning "where (is the subject going) to?", and it is equivalent to the "How to do X?" question, which is an elision of "How (am I going) to do X?".
But there's a similar usage in 'A Study in Scarlet', 1890:
The question was how to identify an unknown prisoner.
This time it is Sherlock himself speaking, and this is correct usage, without any obvious elision. And there's no '?' because it's not a question, even though it states that it is!
This form would also work as "Could you tell me how to X?"
This is where we start digging into what makes a question "properly formed" in English.
We do it in three different ways, depending on the tense of the verb! If you can think of how the answer would be phrased in various tenses, then you twist it in different ways to turn it into a question, which is just a request for that answer.
Question grammar in English is NASTY :(
There are also plenty of questions on StackExchange, like those linked above, which use the "How to...?" syntax - mostly this is "Headline grammar", an abbreviated form of incorrect-but-understood English that people use for headlines, titles of posts, and suchlike, where words are elided for brevity.
Contrary to what other answers assert, the Cambridge Grammar of the English Language (CGEL 2002, ch. 10: §4.5) considers constructions like your example to be sentences, and they explicitly state that the expected punctuation is a question mark if these constructions are used as questions. For illustration, the CGEL uses the following two constructions (CGEL 2002: 873):
[i] What to do in the event of fire
[ii] How to persuade her to forgive him?
The authors describe [i] as a "titular" use of the to-infinitival construction (e.g. used as the title of a "How to" tutorial), and [ii] as a "main clause", which they conclude with a question mark. To quote (CGEL 2002: 873, emphasis mine):
Type [i] is a non-sentential construction: infinitivals of this kind are used as titles of books, articles, etc., or headings for lists, notices, and the like. They have the same function as an NP: compare How to get rich quick and Five ways to get rich quick. In [ii] the interrogative is a main clause, forming a sentence – notice the difference in punctuation between [ii] and [i]. By virtue of forming a sentence, it will normally have illocutionary force: it's a matter of asking, or at least wondering.
The authors however go on to point out that this is a somewhat unusual way to form questions:
This type is somewhat rare and literary; one case of it is in interior monologue, where one is pondering over a question.
So, to answer your question: The CGEL considers your example a valid question type in English, although a rare one, and one that is restricted to specific types of usage. But as a question, the correct and obligatory punctuation to conclude it is the question mark.
Answering strictly in the context of the title of your question, yes, in English questions require that the sentence be ended with a question mark.
As JamesK indicated, your example is neither a question, nor a complete sentence.
Borrowing from the content of your example, a proper question might be:
What are the formatting and layout requirements necessary to display the value of the bar on each bar?
To be brutally clear and simple all questions, because they are questions, necessarily end with question marks. That’s not all but it is much of what defines a question.
(Quite separately and almost equally importantly, since this is ELL, questions end with question marks; a question ends with a question mark. Does that difference between singular and plural make sense to you?)
In the example 'How to display the value of the bar on each bar…' yes, a question mark is compulsory even though what demands that is the context, not the broken grammar… What suggested it could be otherwise?
That kind of usage is not a question in English, or something that people normally say in conversation. By itself, and not as a noun phrase such as in “I wondered how to tell her,” it’s used as a title or a section heading for written directions, not to request help. In that context, it does not take a question mark. Usually, there’s no punctuation after it at all, but sometimes it is followed by a colon and then either a subtitle or a list of instructions. (For example, “How to Bake Bread: A Step-by-Step Guide”)
If you want to turn it into a question that takes a question mark, change “How to ...” to something like “How do I ... ?” or “How would I ... ?” This is how you would normally ask another person.
There are some contexts where you might use this kind of phrase as the answer to a question, such as:
What did you learn in class today?
How to ask for instructions.
There are many other ways of using "how to" in a sentence where you don't need a question mark at the end.
Like with:
He doesn't know how to get there.
Or with a hyphen between them would mean:
adjective
providing detailed and practical advice about the way to do something.
"a how-to book on public speaking"
noun
a book or other guide that provides detailed and practical advice.
"a how-to on processing digital images"
It's merged into a word which basically means something that shows you how to do something.
Example sentences would be:
This is a how-to book on the creation of this amazing statue.
a how-to on solving this mathematical equation.
Even though it's not a complete sentence, it's correct and natural to use fragments like yours with a question mark at the end to ask questions:
How to display the value of the bar on each bar?
It's very common throughout the Stack Exchange network to ask questions this way. In fact, on the front page of this web site right now there are two questions with this structure in their titles:
How to use "and" to connect three verbs?
How to further improve English listening?