How to Find CSS Selectors
Learn how to identify CSS selectors for text areas, forms, and input fields to integrate AI Anywhere helpers into your website.
Watch this video tutorial to learn how to find CSS selectors using browser developer tools.
CSS selectors are patterns used to select HTML elements on your webpage. When creating an AI Anywhere helper, you need to specify which text area or form field the helper should target using a CSS selector.
Method 1: Right-Click Inspect Element (Recommended)
The quickest and simplest method for finding selectors without opening full Developer Tools.
- Right-click on the target element (text area, input field, etc.)
- Select "Inspect Element" from the context menu
-
In the Elements panel:
- Right-click on the highlighted element
- Choose Copy → Copy selector
Method 2: Using Browser Developer Tools
This is the most reliable method for finding selectors on any website.
-
Open Developer Tools:
- Chrome/Edge: Press F12 or Ctrl+Shift+I
- Firefox: Press F12 or Ctrl+Shift+I
- Safari: Press Cmd+Option+I
-
Select the Element:
- Click the Elements tab in Developer Tools
- Click the Select Element tool (cursor icon) in the top-left
- Click on the text area or form field you want to target
-
Copy the Selector:
- Right-click on the highlighted element in the Elements panel
- Select Copy → Copy selector
- Paste this selector into your AI Anywhere helper configuration
#comments
Method 3: Manual Selector Creation
Learn to create selectors manually by understanding HTML structure.
Common Selector Patterns:
Examples:
#message targets <textarea id="message">By Class:
.comment-box targets <textarea class="comment-box">By Type:
input[type="email"] targets email input fieldsBy Attribute:
textarea[name="description"] targets textarea with name="description"
Common Selector Examples
Text Areas:
Input Fields:
Form Elements:
WordPress-Specific Selectors
WordPress powers over 40% of all websites, so here are the most common selectors you'll encounter on WordPress sites.
WordPress Admin Dashboard Selectors:
WordPress Comment Forms:
WordPress Contact Forms (Contact Form 7, Gravity Forms, etc.):
WordPress Page Builders:
WordPress Theme-Specific Selectors:
textarea or input[type="text"]. Test these first before using more specific selectors.
Finding WordPress Selectors Step-by-Step:
-
Identify the WordPress Element:
- Is it a post editor, comment form, or contact form?
- Are you in the WordPress admin dashboard or on the frontend?
- What theme or page builder is being used?
-
Use Browser Developer Tools:
- Right-click on the text area or input field
- Select "Inspect Element"
- Look for WordPress-specific classes or IDs
-
Check for WordPress Classes:
- Look for classes starting with
wp-,gutenberg-, oreditor- - Check for theme-specific classes
- Look for plugin-specific classes (like
wpcf7-for Contact Form 7)
- Look for classes starting with
Common WordPress Plugin Selectors:
WordPress Multisite Considerations:
Testing Your Selectors
Always test your selectors to ensure they work correctly.
-
Open Browser Console:
- Press F12 to open Developer Tools
- Go to the Console tab
-
Test the Selector:
- Type:
document.querySelector('your-selector-here') - Press Enter
- If it returns the element, your selector works!
- Type:
Tips and Best Practices
Selector Priority (Best to Worst):
- ID selectors:
#element-id(most reliable) - Class selectors:
.class-name - Attribute selectors:
input[type="text"] - Tag selectors:
textarea(least specific)
Troubleshooting Common Issues
Selector Not Working?
- Check for typos: Selectors are case-sensitive
- Verify element exists: Use browser console to test
- Check for dynamic content: Some elements load after page load
- Try a simpler selector: Use ID or class instead of complex paths
Multiple Elements Match?
- Make selector more specific: Add parent element or unique attribute
- Use nth-child:
textarea:nth-child(2)for second textarea - Add unique identifier: Ask developer to add ID to target element
Selector Checklist
Before moving forward, make sure you've completed these steps:
Explanation:
- Selector found: You've identified a working CSS selector using one of the methods above
- Tested: You've verified the selector works by testing it in your browser console
- Saved: You've recorded the selector in your Helper configuration or saved it for later use
Next Steps
Now that you know how to find selectors, you can: