{"id":67,"date":"2022-12-12T09:32:00","date_gmt":"2022-12-12T09:32:00","guid":{"rendered":"http:\/\/www.demo.acmethemes.com\/supermag\/?p=67"},"modified":"2024-10-02T09:25:54","modified_gmt":"2024-10-02T08:25:54","slug":"first-letter-capitalized-of-each-word-javascript","status":"publish","type":"post","link":"https:\/\/codehang.com\/index.php\/2022\/12\/12\/first-letter-capitalized-of-each-word-javascript\/","title":{"rendered":"First letter capitalized of each word &#8211; JavaScript"},"content":{"rendered":"\n<p>I am going to show you how you can create a custom method to capitalize the first letter of each word by using String prototype. <\/p>\n\n\n\n<p>However, you can achieve the same results by using CSS, all you need to do is create a class <\/p>\n\n\n\n<p>.capitalize{ <\/p>\n\n\n\n<p>    text-transform: capitalize;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>Despite the fact that it is possible with CSS but sometimes on certain scenarios we need to do this by JavaScript.<\/p>\n\n\n\n<p class=\"codepen\" data-height=\"300\" data-default-tab=\"html,result\" data-slug-hash=\"voEppM\" data-pen-title=\"First letter capitalized of each word  with pure JavaScript - simple and easy\" data-user=\"TayabRaza\" style=\"height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\">\n  <span>See the Pen <a href=\"https:\/\/codepen.io\/TayabRaza\/pen\/voEppM\">\n  First letter capitalized of each word  with pure JavaScript &#8211; simple and easy<\/a> by Tayab Raza (<a href=\"https:\/\/codepen.io\/TayabRaza\">@TayabRaza<\/a>)\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/span>\n<\/p>\n<script async src=\"https:\/\/cpwebassets.codepen.io\/assets\/embed\/ei.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>I am going to show you how you can create a custom method to capitalize the first letter of each word by using String prototype. However, you can achieve the same results by using CSS, all you need to do is create a class .capitalize{ text-transform: capitalize; } Despite the fact that it is possible with CSS but sometimes on certain scenarios we need to do this by JavaScript. See the Pen First letter capitalized of each word with pure JavaScript &#8211; simple and easy by Tayab Raza (@TayabRaza) on&hellip;<\/p>\n","protected":false},"author":1,"featured_media":232,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6,7],"tags":[16,17,18],"class_list":["post-67","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-featured","category-html","category-javascript","tag-html","tag-html5","tag-javascript"],"_links":{"self":[{"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":3,"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":273,"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions\/273"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/media\/232"}],"wp:attachment":[{"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codehang.com\/index.php\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}