Is it grammatically correct to ask, "How to do something?"

"How to list files in a directory in C?"

"How to avoid special char(*,%,^..) in keydown event?"

"How to texture a quad in Gtk?"

"How to stop the title bar from blocking the main thread in Metal?"

These are all examples of questions/comments I could/have seen on StackOverflow. Is the complete sentence, "How to do something?" wrong? I doesn't sound right, but is it wrong?

How to ask how to do something correctly?


It's the difference between a main clause and a content clause, and a tensed vs infinitival interrogative construction.

Interrogative main clause :

How does one list files in a directory in C?

Interrogative content clause:

Please tell me how one lists files in a directory in C.

The subordinate clause above is tensed - it has a a primary verb form.

Infinitival interrogative clause:

Please tell me how to list files in a directory in C.

Here we have an infinitival interrogative clause. These are allowed as subordinates only - where interrogative content clauses are allowed. (CaGEL p1264)

Since it's so prevalent on the internet, using the subordinate infinitival interrogative without a matrix clause might have slipped into informal use, but it would not be accepted as grammatical in any serious conversation or publication.


These are not questions. These are relative infinitives, like what to order, who to tell, when to leave, or which one to pick. Putting a question mark after them does not make them questions. Relative infinitives are often used in lists, like journalists' bullet points: what, where, when, how, who, why, ..

They can be used as embedded question complement clauses, with the right verbs and constructions:

  • He asked her what to do.
  • She knows when to do it.
  • How to make sure it works is a problem.

But they aren't questions by themselves. There are several ways to make questions in English, but these are sposta be Wh-questions. There's really only one way to make them, and it doesn't involve infinitives. Here's the rule:

  1. Start with a statement that has a missing or unknown part you want to ask about, e.g,
    You can list files in Directory A by using Program ??
  2. Substitute the appropriate Wh-word for the missing part, e.g,
    You can list files in Directory A how
  3. Form a Yes/No question from the modified statement, e.g,
    Can you list files in Directory A how?
  4. Move the Wh-word to the beginning of the Yes/No question, e.g,
    How can you list files in Directory A?

Note that the question has its subject (you) and its first auxiliary inverted (can you instead of you can). It doesn't use to.

Infinitives with to are strictly subordinate clauses. But, in posters, advertisements, slogans, songs, bullet lists, raps, movies, slideshows, poems, and other spontaneous or artistic language, grammar does not constrain.


Yes, they are grammatically incorrect, because the are sentence fragments. However, I wouldn't call them "wrong", because there is no rule that says that the titles of the questions in stack overflow have to be 100% grammatically correct. They get the poster's meaning across in a clear and concise way.