Posted: December 4th, 2009    By: Devin Walker   
WordPress IconI like to design websites that are W3C Compliant.  Your WordPress theme may require some tweaking to be valid.  One error I kept receiving was: Attribute "role" is not a valid attribute. Did you mean "frameborder" or "scrolling"?  I will show you how to correct this error. 
Simply put, to correct the error we are just going to remove the role="search" attribute from your theme's search form.  1. Navigate to your theme folder within your WordPress directory.  2. Open the file containing your search form in the theme. It may be called "searchform.php" or something similar. 3. Remove the role="search" attribute and save.
<form method="" action="/”>
<input type="text" value="” name=”s” id=”s” />
Line 124:
$form = '<form role="search" method="get" id="searchform" action="' . get_option('home') . '/" >
Should now read:
$form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
4. Replace the file on your web server.

Related posts:

  1. WordPress Alternating Classes It's often very useful to have alternating classes in for styling purposes. Let's say you want every other row to be a darker shading, this is very common and I'll show you how to implement this in WordPress using a simple bit of code. For my example here I will show you how to create [...]...
  2. WordPress: If URL is Homepage then do this… Question: In WordPress how to I make sure the page loaded is the homepage URL and display some data if the standard WordPress Conditional Tags are not working for my theme?! Answer: Here's a quick snippet of code that will give you an option to do something if these WordPress basic conditional tags are not [...]...
  3. GoDaddy WordPress Sites Infected by HolasionWeb Malicious Code Have you gotten calls from your clients hosted on GoDaddy about their WordPress site's being 'hacked'? Or perhaps this happened to you yourself. It seems there's a new report of thousands of WordPress sites being infected by malicious javascript inserted on their WordPress website. It's not everyday that WordPress gets 'hacked' by something/one.  Today one [...]...
  4. Embed Videos with Valid W3C Markup (Youtube, Hulu, Google) As a web designer, I like to have my site validated by the W3C Validator and display the banner on each one of my site's pages. I embed videos from YouTube on this blog, therefore I must do it in a way that is valid. This tutorial is the code I use to embed Youtube [...]...
  5. WordPress: Removing ‘Search For’ text from Search Box While I was customizing my WordPress theme I decided that the "Search for" text before the Search Box was unneccessary. This is how to take it out using CSS. This way, if you have to upgrade your WordPress version in the future you won't have to modify the general-template.php file again to comment out the [...]...
  • Carl

    Thanks, lead me in the right direction. But, you can do this without altering the core WP files. Make a new theme file searchform.php with something like

    <form method="" action="/”>
    <input type="text" value="” name=”s” id=”s” />

    And modern versions of WP will use this instead. For more see: http://themetation.com/2008/07/17/how-to-create-wordpress-themes-from-scratch-part-3b/#11

  • http:/www.dlocc.com Devin Walker

    Thanks, and very valid point. I’ve updated the article to reflect this…