Sunday 21 May 2017

How to Style Google Custom Search on your Website

How to Style Google Custom Search on your Website


Google Custom Search makes your website searchable using the same technology that powers the main Google.com search engine. You just have to add a JavaScript snippet to your template and visitors will be able to easily find content they are looking for on your website.

Google Custom Search, by default, uses the classic Google layout – blue titles, green links and black snippets – for styling search results on your site. You do have an option to choose a different color scheme and font family for your search results* but that’s pretty much it.



GOOGLE CUSTOM SEARCH WITH CUSTOM CSS STYLES

You cannot add these custom styles though the Custom Search editor but you can write simple CSS rules that will bring the same effect. The idea is simple. As annotated in the above screenshot, every element in the search results page has a class associated with it. You can use set the style for a class as display:none to hide a particular element or use the regular font, color, border properties to stylize that element.

For instance, lets target the info box in search results that displays the result count (class=gsc-result-info). If you would like to hide that particular block, you can add a rule in your stylesheet that says .gsc-result-info { display:none; } and the count won’t show up anymore. Similarly, you can say .gs-snippet {display:none} to only display titles and not snippets.

The Custom Search editor won’t let you change the font size the title and results but with CSS, you can do that easily.

Here are some more CSS rules that you may use to style your Custom Search engine.

<style type='text/css'>
    
    /* Use a different font family for search results */
    .gs-title, .gs-snippet {
        font-family: courier;
    }
    
    /* Add a border between individual search results */
    .gs-webResult {
        border: 1px solid #eee;
        padding: 1em;
    }
    
    /* Do no display the count of search results */    
    .gsc-result-info {
        display: none;
    }
    
    /* Hide the Google branding in search results */
    .gcsc-branding {
        display: none; 
    }
    
    /* Hide the thumbnail images in search results */
    .gsc-thumbnail {
        display: none;
    }
    
    /* Hide the snippets in Google search results */
    .gs-snippet { 
        display: none;
    }
    
    /* Change the font size of the title of search results */
    .gs-title a { 
        font-size: 16px;  
    }
    
    /* Change the font size of snippets inside search results */
    .gs-snippet {
        font-size: 14px;
    }
    
    /* Google Custom Search highlights matching words in bold, toggle that */
    .gs-title b, .gs-snippet b {
        font-weight: normal;
    }
    
    /* Do no display the URL of web pages in search results */
    .gsc-url-top, .gsc-url-bottom {
        display: none;
    }
    
    /* Highlight the pagination buttons at the bottom of search results */
    .gsc-cursor-page {
        font-size: 1.5em;
        padding: 4px 8px;
        border: 2px solid #ccc;
    }
    
</style>

These rules will also come handy when you don’t have the permission to change the default look and feel from the Custom Search editor.

[*] If you would like to use a custom color scheme for your custom search engine, go to google.com/cse, choose your search engine and then switch to the Look and Feel tab. Here you can choose different colors for the titles, URLs and snippets, switch to a different font family (default is Arial) and also choose a different color for the background.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Labels

404 AdBlock Add-on Airtel GPRS Trick Airtel SMS Trick Alexa Amazon Amazon Kindle Amazon Prime Android Android 8 Android Oreo antivirus Apple Apple Mac ASCII Audacity Audio Authotkey Backup Balance Transfer in Vodafone Battery Bing Blogger Blogging Bookmarklet Browser Camera Chromebook clock Cloud colors command lines Computer Computer Tricks configuration Contact Creative Commons Credit Card CSS devolop DIY Doodle DOS Download Dropbox E-Mail eBook Email Email Attachment Embed Encryption English Error Evernote Eyes Facebook Facebook Tricks Feedburner Flipkart Font Foursquare Free Internet Free sms trick in Vodafone G Mail Gadget Game Getty Images GIF Gists Github Google Google AdSense Google Analytics Google Apps Google Chrome Google Contacts Google Currents Google DNS Google Docs Google Drive Google Earth Google Font Google Forms Google Images Google Map Google Photos Google Play Store Google Plus Google Print Google Reader Google Script Google Sheets Google Spreadsheet Google Translate GPRS Setting GPS Hacking Health App HelloFax Hindi Hoodie HTML Icons idea Image Editing Images IMEI Indian Railways Infographics Instagram Internet Internet Explorer Internet Tricks iOS iPad iPhone IRCTC iTunes iTV JavaScript JioCinema JioTV Junglee Kindle Language Translation Laptop Laptop. TV Life Time FREE GPRS Life-Style Link Linkedln Linux logo Make Money Online Microdoft Powerpoint Microdoft Word Microsoft Office Microsoft Outlook Mobile Mosaic Music Name Networking nexus Notepad OCR Online Shopping Open DNS OS Outlook Password PDF Petya Phillips Hue Lights Photogtraphy Pixel Play Station Podcasts Pokemon Pokemon Go Polls Print Productivity Proxy Server Pushbullet QR Code Ransomware Reddit Reliance Hack GPRS Reliance Jio RGB Ringtone Router RSS Safe Mode Samsung Galaxy S Scrabble Screen Capture Screen Sharing Screencast Secrets Security Send free sms from PC SEO Sierra Skype Slideshare SMBv1 SMS Snapchat Snapdeal Social Media Solution Sound Device Speech Recognition Sql Steam Sync Synology NAS Tata Docomo GPRS trick Teleprompter Torrent Trick Tricks TV Twitter UltraISO Unicode Unknown Extension Unlimited 2GB Unlimited 3GB Unlimited GPRS USB USB Security Key Video Editing virtual desktop Virus attack VLC Vodafone 110% working trick for GPRS Vodafone 3g Vodafone GPRS VPN wallpapers WannaCry Web Design Web Domain Website Wget Whatsapp WiFi Wikipedia Windows Windows 10 Windows 10 S Windows KN Windows Tricks windows updates Winows N Wolfarm Alpha WordPress XBox YouTube Zip
Twitter Delicious Facebook Digg Stumbleupon Favorites More