Can the web page title be set to be dynamic?

I want to let some part to be updated in title, if any changes occur, an automatic update resulting in a bit of word addition to the title.

Example : the original one : "what is the title name"

Now after setting to automatic update when a event as an answer is posted - "what is the title name (1 answer)"

5 Answers 5


Your question needs to be clearer. Dynamic how? When getting information from a database? Or when a user interacts with a web page in such a way that a new page is not requested from the server?

Here's a generallized answer that hopefully helps to clear things up. The title of a page can be dynamic in two ways:

  • it is done serverside before being sent to the browser. This is how most dynamic pages generated. Whatever output is generated is what search engines will see. Any changes to the information in the database will be reflected in the page as soon as the new information is comitted in the databbase.

  • it is changed via JavaScript after the page is loaded in the browser. This change is not seen or indexed by search engines.


Edited to reflect the clarification posted by the question asker

You can change the title of a page after it is loaded using JavaScript (the snippet in Shedokan's answer will work). Keep in mind that search engines only see the original output of a page when they request it. To use your example, if answers are added to the page after they crawled it you will need to wait until they crawl it again before those changes are reflected in the search engines indexes.

  • I think the question is plenty clear: "Can I change the title of the page while the user is on the page." Seems clear enough to me; I think you're overthinking it. Downvoted because @Shedokan gave a useful answer and this is not one. Nov 2, 2011 at 19:13
  • 1
    They do not clarify if the change occurs client side or server side. Until they do the question is not clear.
    – John Conde
    Nov 2, 2011 at 19:15
  • If the question requires clarification, wouldn't a comment on the question be more appropriate? Submitting an "answer" that's primarily a request for clarification... that's not what answers are for, unless I'm mistaken. Nov 2, 2011 at 19:19
  • If I only requested clarification a comment on the question would be more appropriate. But since I gave an answer that addressed the question from both a server side change and client side change I included it as part of my answer to help illustrate why the answer needs clarification.
    – John Conde
    Nov 2, 2011 at 19:21
  • 1
    @sequoia, I think you're being overly critical. John Conde knows how the stackexchange works and has a vast expertise of 'the web'. He did the best he could given the question asked in it's original format, with updates after clarification.. what more could you want?
    – Anonymous
    Nov 4, 2011 at 7:28

If you want to change the page title without reloading the page then you'll have to do it in javascript:

document.title = 'Your new title';

You'll have to set the title even if you just want to change a part of it.

And if you want to update the title when a refresh occurs then you'll have to do it using your server side scripts.


In ASP.NET your dynamic pages inherit from System.Web.UI.Page which has a Title property, which you can set to whatever variable you want. So you may have some part of the title, which is shared by all the pages, stored in a file with other globals, and in the Page_Load method of a specific page you use it to "compute" the individual title.


If you want this done on the server side, you can set the title as a variable. Depending on your condition, you can then set the variable (title) to what you want. It's hard to tell exactly what you want to do, but a simple example of doing this--on the server side--using ColdFusion would be:

<cfparam name="title" default="No Title" type="string" />

<cfif isDefined("FORM.myName") AND FORM.myName NEQ "No Title">
  <cfset title = FORM.myName&"'s Page" />


  <form name="formName" action="thispage.cfm" method="post">
    <label for="myName">Name: </label>
    <input type="text" id="myName" name="myName" value="" />
    <input type="submit" />

<cfparam name="title" default"No Title" type="string" /> sets the default title value when the page first loads. The default title will be No Title. When a user enters a name on the form, and submits the form back to itself, the title will change to the value they entered. For example, if the user enters Tom, then submits the form, the title will change from No Title to Tom's Page.

  • -1 the OP asked to change the title after the pag has loaded, your solution actually needs to load a new page to get a different title.
    – Shedokan
    Jun 2, 2017 at 12:04

Everything and anything can be dynamic on your page. You could even let one URL serve up a random page if you want.

If it's a good idea? I doubt. The question is what the search engines will make of it. Most likely it will not be beneficial SEO-wise.

Edit after "positive" feedback from @Shedokan, who reads the quastion a little different (as in changing the title dynamically, without any active refresh from the client side).

There are a few techniques to do so after the page has loaded, the latest (but not yet very reliable) way is using websockets. A more traditional (and currently more reliable) way is using long polling. There are several other "Push technologies" as well. There are libraries out there that will try websockets and automatically fallback to long polling if websockets is not working. I personally have used SignalR (using the .Net framework) which works very well. Note that if the info is important or requires immediate action, you should consider using notifications in addition, since the above mentioned techniques will usually only work while the browser is visible (at least on mobile devices like iPads).

  • 1
    This is a comletely useless "answer"...
    – Shedokan
    Jun 2, 2017 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.