ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Create Text Color Changer using Notepad in Simple Steps

Updated on November 3, 2012

Use HTML Javascript in notepad to create the magic !!


Notepad is a great feature in windows machines to create various applications with a simple knowledge of HTML combined with power of Javascript.

You don't require any special skills, just need to type in a notepad and have fun. Here I have tried to create a simple text color changer using HTML and javascript tags in notepad. We will go slow and line by line, explaining the tags and at last getting a sweet simple color changer webpage.

Open a notepad

First let us open a notepad. On your system go to Start > All Programs > Accessories > Notepad.


Start the magic, First few lines !!

< HTML><body><h1><p> <br> <strong>tags

html: The starting <html> and the end </html> tags describes the page as a webpage.

body: The starting <body> and the end </body> tags are contained within the html tags and contents between the body tags are displayed on the webpage to the user.

h1: The starting <h1> and the end </h1> tags define the heading text for the webpage.

p: The starting <p> and the end </p> tags define the paragraph cotent for the webpage. The id attribute ( id="trick") uniquely identifies the paragraph object.

br: The <br> tag provides a line break between contents in the webpage

strong: The start <strong> and the end </strong> tags change the display text property to bold.

In the above lines we have defined the page as webpage using the html tag and used the body tag for content display. h1 serves to add headline to the page and tag p servers as adding the paragraph content to the body. The id attribute used in the p tag can be used as object reference to change properties of the tag using javascript, we will delve into the same later.

So now we have our content lets now proceed to add in the Pick a color list to the webpage.

Add the select tags between the body tags

<Select>, <option>, <label> tags

Select: Used to create dropdown list in a webpage.

Option: Options define the option to choose from in the dropdown list. The value attribute provides a unique value for the selected dropdown option.

label: The label tag renders the text as innerHTML, which can be later used to populate values dynamically using javascript.

In the above lines we have created a dropdown list with various colornames. Now we need to use Javascript to link the dropdown to the paragraph, such that whenever the user chooses a color name from the dropdown the paragraph content reflects the same color for the text rendered.

Javascript function to link dropdown option to paragraph

Javascript is a light weight programming language for webpages. You can perform many actions by just placing javascript start <script> and end </script> tags within the HTML body tags. Each action to be performed from a html tag can be achieved by calling a javascript function. A java script function is defined as function(valuename){ <Action to be performed>} and is placed between the <script> tags.

Now let us delve into the javascript code used above:


document.getElementById("trick") finds the p tag object with id trick and as seen above the object is assigned to x.[optionList.selectedIndex].value;

Now as x contains the reference to the p trick tag, we can change its properties using various attributes that would define a p tag.

In the above line we use the style attribute of the p tag and then refer to the color attribute of the style property.

optionList.options[optionList.selectedIndex].value gets us the value for each option selected by the user in the dropdown. For example if the user selects the Invisible option, value of white gets assigned to the color attribute of P tag. Thus changing the color of the P text to white.


The label object is found using the colorValue id and is assigned to y.


Now we populate the label value same as the option value selected by the user.;

Now assign the selected option value to the color attribute of the label, to display the label text in the same color.

Lets now add in the script tag and its content between the ending </p> tag and the begining <select> tag.

Ok now we need to call the above function changeColor(optionList) whenever the user selects a option value from dropdown and pass the select tag object as optionList.

This can be achieved by adding the onchange attribute to the select tag.

The onchange attribute calls the defined javascript function whenever the select option (dropdown value) is changed.

<select onchange="changeColor(this)"> where this passes the current select option object refernce.

Entire Code Snippet !!


<h1>Color Changer</h1>

<p id="trick">
<strong>I can change my color, Don't believe ? Pick a color from the Drop-down below and see the Magic !! </strong> <br>


function changeColor(optionList)


<select onchange="changeColor(this)">
  <option value="black">Pick a Color</option>
  <option value="White">Invisible</option>
  <option value="Red">Red</option>
  <option value="Green">Green</option>
  <option value="Blue">Blue</option>
  <option value="Yellow">Yellow</option>
  <option value="Orange">Orange</option>
  <option value="Pink">Pink</option>
  <option value="grey">Grey</option>
  <option value="Magenta">Magenta</option>
  <option value="Crimson">Crimson</option>
  <option value="Cyan">Cyan</option>
  <option value="BurlyWood">BurlyWood</option>
  <option value="DarkRed">DarkRed</option>
  <option value="Purple">Purple</option>
<br><br><Strong>Now my Color is: </Strong> <label id="colorValue">Black </label>

Finishing Touches !!

We have almost completed the entire marathon and are just near the finishing line now. So why wait ? Lets touch the finishing rope and bow out to the Loud cheerful audience !!

You can now save the notepad with the entire content (you can also copy and paste the whole code content above to a notepad) by clicking File > Save As

And input file name as 'colorChanger.html' or '<name of your choice>.html' , just need to make sure your file has a .html extension, so that the browser recognises it as a webpage.

And in File type choose 'All Files' and click save.

Hurray !! we are done. Now double click on the colorChanger.html file, it will launch in your default browser as a webpage.

Select any value from the dropdown and see the magic.

Save the file and Play with it !!


We have learnt here how to build a color changer using a simple notepad and some basic knoweldge of html and javascript. Javascript is a powerful yet simple language which can work wonders for you. You can even do animations by placing pictures instead of the p tag text in the above code snippet. I will try and get an example for same soon.

Till then if you have any questions or want to try anything that's in your mind, don't hesistate to leave me a comment and I will reply back promptly !!

Hope you had a good learning experience !!

Thanks !!


    0 of 8192 characters used
    Post Comment

    No comments yet.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)