Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coupe WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Comment ajouter facilement des CSS personnalisés à votre site WordPress

Note éditoriale : Nous percevons une commission sur les liens des partenaires sur WPBeginner. Les commissions n'affectent pas les opinions ou les évaluations de nos rédacteurs. En savoir plus sur Processus éditorial.

Vous souhaitez ajouter des CSS personnalisés pour modifier l’aspect et la convivialité de votre site ?

L’ajout de CSS personnalisés vous aide à modifier la mise en page et l’Apparence de votre site, ce qui n’est pas possible par les options par défaut. L’utilisation du FTP est trop déroutante pour la plupart des débutants, mais il existe d’autres moyens d’ajouter des feuilles de style CSS personnalisées.

Dans cet article, nous allons vous afficher comment ajouter facilement des CSS personnalisés à votre site WordPress sans modifier aucun fichier du thème.

Adding custom CSS to your WordPress site

Pourquoi ajouter des CSS personnalisés dans WordPress ?

CSS est l’abréviation de Cascading Style Sheets (feuilles de style en cascade) et est un langage qui vous aide à styliser votre site WordPress. CSS et HTML vont de pair car CSS est utilisé pour styliser différents éléments HTML comme la couleur, la taille, la mise en page et l’affichage.

L’ajout de CSS personnalisé aide à personnaliser la conception et l’apparence de votre site, ce qui n’est pas possible via les options par défaut. Cela vous donne plus de contrôle, et vous pouvez facilement apporter des modifications à votre thème WordPress avec quelques lignes de code.

Par exemple, disons que vous souhaitez modifier la couleur d’arrière-plan de chaque publication individuelle au lieu d’utiliser la même couleur sur l’ensemble du site. En ajoutant un code CSS personnalisé, vous pouvez personnaliser l’arrière-plan d’une publication ou d’une page spécifique.

De même, vous pouvez modifier le style et l’apparence des catégories de produits sur votre boutique e-commerce à l’aide de CSS supplémentaires.

Cela dit, voyons les différentes façons d’ajouter des CSS personnalisés à votre site WordPress. Vous pouvez cliquer sur le lien ci-dessous pour passer directement à la section qui vous intéresse :

Méthode 1 : Ajout d’une CSS personnalisée à l’aide du personnalisateur de thème

Depuis WordPress 4.7, les utilisateurs/utilisatrices peuvent désormais ajouter des CSS personnalisés directement depuis la zone d’administration de WordPress. C’est super facile, et vous pourrez voir vos modifications avec une prévisualisation en direct instantanément.

Tout d’abord, vous devez vous rendre sur la page Apparence  » Personnalisation de votre Tableau de bord WordPress.

The WordPress theme customizer

Cela lancera l’interface du personnalisateur de thème WordPress.

Vous verrez la Prévisualisation en direct de votre site avec un tas d’options dans le panneau de gauche. Cliquez sur l’onglet « Additional CSS » dans le panneau de gauche.

Click on additional CSS

L’onglet se diapositive pour afficher une boîte simple où vous pouvez ajouter votre CSS personnalisé. Dès que vous aurez ajouté une règle CSS valide, vous pourrez la voir appliquée dans le volet de prévisualisation en direct de votre site.

Add CSS and publish

Vous pouvez continuer à ajouter du code CSS personnalisé jusqu’à ce que vous soyez satisfait de l’aspect de votre site.

N’oubliez pas de cliquer sur le bouton « Publier » en haut de la page lorsque vous avez terminé.

Note : Tout CSS personnalisé que vous ajoutez en utilisant le personnalisateur de thème est uniquement disponible avec ce thème particulier. Si vous souhaitez l’utiliser avec d’autres thèmes, vous devrez le copier et le coller dans votre nouveau thème en utilisant la même méthode.

Méthode 2 : Ajout de CSS personnalisés à l’aide de l’extension WPCode

La première méthode vous permet uniquement d’enregistrer les feuilles de style CSS personnalisées pour le thème activé. Si vous modifiez le thème, vous devrez peut-être copier et coller votre CSS personnalisé dans le nouveau thème.

Si vous souhaitez que votre CSS personnalisé soit appliqué quel que soit le thème WordPress que vous utilisez, cette méthode est faite pour vous.

WPCode est la meilleure extension d’extraits de code personnalisés sur le marché, avec plus d’un million d’utilisateurs/utilisatrices. Il facilite l’ajout de code personnalisé dans WordPress et est livré avec des fonctionnalités telles qu’une bibliothèque d’extraits de code intégrée, une logique conditionnelle, des pixels de conversion, et plus encore.

La première chose à faire est d’installer et d’activer l’extension gratuite WPCode. Si vous avez besoin d’aide, veuillez consulter notre guide sur l ‘installation d’une extension WordPress.

Une fois activée, il suffit de se rendre dans la rubrique  » Code Snippets  » + Ajouter nouveau depuis le tableau de bord WordPress.

Survolez ensuite l’option « Ajouter votre code personnalisé (nouvel extrait) » dans la bibliothèque d’extraits de code, puis cliquez sur le bouton « Utiliser l’extrait ».

Add custom CSS using the WPCode plugin

Ensuite, en haut de la page, ajoutez un titre à votre extrait CSS personnalisé. Il peut s’agir de n’importe quoi qui vous aide à identifier le code.

Ensuite, écrivez ou collez votre CSS personnalisé dans la case « Prévisualisation du code » et définissez le « Type de code » en choisissant l’option « Extrait CSS » dans le menu déroulant.

Paste custom CSS code and select CSS Snippet as the Code Type

Ensuite, défilez jusqu’à la section  » Insertion  » et sélectionnez la méthode  » Auto-Insert  » si vous souhaitez exécuter le code sur l’ensemble de votre site WordPress.

Si vous souhaitez uniquement exécuter le code sur certaines pages ou publications, vous pouvez choisir la méthode « Code court ».

Choose an insertion method

Vous devez maintenant retourner en haut de la page et permuter le commutateur sur « Actif », puis cliquer sur le bouton « Enregistrer l’extrait ».

Activate and save CSS snippet

Vous pouvez maintenant consulter votre site WordPress pour voir le CSS personnalisé en action.

Méthode 3 : Ajout de CSS supplémentaires avec l’Éditeur de site complet (Éditeur de site)

Une autre façon d’ajouter des CSS personnalisés dans WordPress est d’utiliser l’Éditeur de site complet (Éditeur de site). Avec l’Éditeur de site complet, vous pouvez modifier la mise en page et la conception de l’ensemble du site à l’aide de l’éditeur de blocs de WordPress, tout comme lorsque vous modifiez un article ou une page de blog.

Notez bien que l’éditeur de site complet est uniquement disponible pour les thèmes sélectionnés. Pour plus de modifications, vous pouvez consulter notre article sur les meilleurs thèmes WordPress d’édition de site complet.

L’utilisation d’une extension pour ajouter du CSS est un peu plus facile. Aucun, si vous préférez ne pas utiliser d’extension, nous allons vous afficher comment accéder au personnalisateur même s’il n’est plus disponible dans votre menu d’administration.

Il vous suffit de vous connecter à l’interface d’administration de WordPress.

Ensuite, il vous suffit de copier et de coller l’URL ci-dessous dans votre navigateur, en remplaçant « exemple.com » par le nom de domaine de votre propre site.

https://example.com/wp-admin/customize.php

Cela vous amènera à une version limitée du personnalisateur du thème. Dans le menu de gauche, vous devriez voir l’option d’ajout de CSS personnalisé en bas.

Il suffit de cliquer sur l’onglet « Additional CSS ».

Select additional CSS option

Saisissez maintenant votre code CSS dans la zone Additional CSS.

Après avoir ajouté le code, il suffit de cliquer sur le bouton « Publier ».

additional css in fse theme

Utilisation d’une extension CSS personnalisée ou Ajout de CSS dans le thème

Toutes les méthodes décrites ci-dessus sont recommandées pour les débutants. Les utilisateurs/utilisatrices avancés peuvent également ajouter des CSS personnalisés directement à leurs thèmes.

Cependant, il n’est pas recommandé d’ajouter des extraits CSS personnalisés dans votre thème parent. Vos modifications CSS seront perdues si vous mettez accidentellement à jour le thème sans enregistrer vos modifications personnalisées.

La meilleure approche consiste à utiliser un thème enfant à la place. Cependant, de nombreux débutants ne veulent pas créer un thème enfant. Ajouté à l’ajout de CSS personnalisé, les débutants ne savent souvent pas comment ils vont utiliser ce thème enfant.

L’utilisation d’une extension CSS personnalisée vous permet de stocker votre CSS personnalisé indépendamment de votre thème. De cette façon, vous pouvez facilement changer de thème, et votre CSS personnalisé sera toujours là.

Une autre excellente façon d’ajouter des CSS personnalisés à votre site WordPress est d’utiliser l’extension CSS Hero. Cette merveilleuse extension vous permet de modifier presque tous les styles CSS de votre site WordPress sans écrire une seule ligne de code.

CSS Hero change bottom margin

Vous pouvez également ajouter des CSS personnalisés avec l’extension SeedProd. SeedProd est un constructeur de site web drag and drop qui vous permet de créer des thèmes WordPress personnalisés et des pages d’atterrissage pour votre site WordPress. Vous pouvez facilement modifier les réglages CSS globaux, aucun code n’est nécessaire.

Add custom CSS with SeedProd

Nous espérons que cet article vous a aidé à ajouter des CSS personnalisés à votre site WordPress. Vous pouvez également consulter notre guide sur la façon de choisir le meilleur logiciel de conception web, et les meilleurs plugins de constructeur de page WordPress drag & drop.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Divulgation : Notre contenu est soutenu par les lecteurs. Cela signifie que si vous cliquez sur certains de nos liens, nous pouvons gagner une commission. Consultez comment WPBeginner est financé, pourquoi cela compte et comment vous pouvez nous soutenir. Voici notre processus éditorial.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

L'ultime WordPress Toolkit

Accédez GRATUITEMENT à notre boîte à outils - une collection de produits et de ressources liés à WordPress que tous les professionnels devraient avoir !

Reader Interactions

73 commentairesLaisser une réponse

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Qasim Saeed says

    Hello if I want to add a custom CSS on a specific page without any plugin then what? I think we add this via function? can you please tell me how to add CSS via functions.php and what is the best and secure way to add CSS for a specific page

    • WPBeginner Support says

      You do not need to use functions to add CSS to specific pages, you would target the specific page in your CSS selector to have it only affect a single page on your site.

      Administrateur

    • WPBeginner Support says

      Both options are valid choices it depends on personal preference and if the theme has the option in the editor.

      Administrateur

      • Jiří Vaněk says

        Thanks for the clarification, I wasn’t sure if, for example, a snippet using WPCode would be faster for the site’s response than integrating it into the template itself. So if it doesn’t matter, I’ll probably stick to best practice and keep it integrated in the template.

  3. Bogdan says

    Hey, this article is very good. One question though: Don’t I have to see the HTML page to add custom CSS? How do I add custom CSS if I don’t know the selectors and all of that?

  4. Jitin Mishra says

    Great article to add custom CSS in WordPress website. We are looking forward to such more informative posts

  5. Mohsin says

    I want to change my WordPress menu to mega menu with coding. Can i convert my website menu to mega menu using html, css and js? I don’t want to use a plugin for this work. If we add new functionality to WordPress website with custom coding, what are the best practices for which this custom work did not go ahead by updating theme or WordPress. Thanks!

  6. vijay v says

    can we add external CSS file( by moving custom CSS) to increase page speed( after I added custom CSS it decreased loading speed), if yes how to do it?

    thank you in advance

  7. Latonya Moore says

    This is great but is there a way to only add css to one page? Example I only was to show or hide by hover or mouseover on one text.

  8. shiva says

    I have made some Changes in my website by editing some css codes in theme editor. What will happen if I update my wordpress to next version. Does it get error or gets back to base theme or my code will appear even after updating my wordpress just like before updation.

    • WPBeginner Support says

      If you added your CSS in the Appearance>Customizer>Additional CSS area then your CSS changes will remain when you update your site.

      Administrateur

  9. Jo says

    I have not quite finished building my website, but have updated from the free version so I can use css to make changes. My site is not yet live. With the upgrade to the premium version the update button has now changed to publish. Does this mean that when I click on publish to save any changes it will make my site live?
    Also, I can’t remember which theme I used, how do I find out which theme I am using?
    Thanks

  10. Bruce William Taylor says

    « The tab will slide to show you a simple box where you can add your custom CSS. As soon as you add a valid CSS rule, you will be able to see it applied on your website’s live preview pane. »

    I already know WHERE to add the CSS. How do I know what CSS to add? How do I know what the « valid CSS rules » are?

    • WPBeginner Support says

      Hey Bruce,

      For that you will need to learn some basic CSS. There are several websites that have step by step CSS tutorials for beginners. We recommend w3schools as they allow you to practice CSS with a live try it out box.

      Administrateur

  11. Aditya Khuteta says

    Hi there! I want to change the size of price text on my website becuase the price text is too small there. Please guide me to do so.
    Thanks

  12. Frank Lurz says

    2 Questions:

    1. Just so I’m clear, « plugins » are substitutes for writing CSS, a difficult task for those of us who know nothing about CSS — is that right?

    2. Plugins listed for downloading on the WP plugins page are available for installation only to subscribers who have paid for the « Buisness » Plan, is that right?

  13. Annie Mitchell says

    Hi,

    I am a novice when it comes to building and designing websites and have no knowledge of css. I am using the Sydney theme on my website – and I have somehow managed to turn my paragraph font white. I have googled and notice a gentleman had the same issue. He fixed it downloading a plugin and using a custom css however I have tried and had no luck.

    The css which he advised using is –

    .entry-page p, .entry-post p {
    color: black !important;
    margin: 0 !important;
    padding: 0 !important;
    }

    but I am not sure why it is not working for me. Any help would be much appreciated.

    Thanks,

    Annie

    • WPBeginner Support says

      Hi Annie,

      First we will recommend you to turn off all your WordPress plugins by deactivating them. After that, visit your website to see if this resolved your issue. If it did, then this means a setting in one of your plugins was causing the problem. If it doesn’t solve the issue, then try switching to a default theme like Twenty Seventeen. If that does fix your issue, then it means that some where in your theme you have changed the font settings.

      If nothing works out, then you can try this custom CSS:

      p { 
      color:#000; 
      }

      Administrateur

  14. Jose says

    One of the plugins (Simple Custom CSS) hasn’t been updated for 2 years which in the world of WordPress plugins is a very long time. This is a security risk so I would personally look for an alternative.

  15. Rebecca says

    Hi
    Sorry i don’t know anything about css and I am trying to solve a problem with not being able to search for plugins, but that is another story! I am posting here now because i am getting this message when i go to appearance / edit css / aditional css

     » There is 1 error which must be fixed before you can save.
    Update anyway, even though it might break your site? »

    Is this something i shoudl worry about?

    the text in the box below it reads …

    and just here there is a red fullstop

    Hope someone can help.

    Thank you

    • WPBeginner Support says

      Hi Rebecca,

      You can copy the CSS and paste it in a text file and save it as backup. Now delete every thing in Additional CSS box and start adding your custom CSS one rule at a time until the error appears again. This will help you locate the error and fix it.

      Administrateur

  16. James says

    This no longer works for free accounts. The CSS option is no longer there and you need a business account to install a relevant plugin.

  17. scott says

    Before WP version 4.9, I used to be able to cut and paste my custom CSS (from the WP customizer) and paste it into Windows Notepad (and it would keep the formatting. I did this often to save it as a back up when I was adding new custom CSS — in case I made a mistake.

    Now when pasting it in Notepad, it just runs all the CSS together without the line-by-line formatting in Notepad.

    Any idea why or how I can fix it? I already have « word wrap » mode set in Notepad.
    Thanks.

  18. Joe MacMillan says

    This site is really good. My site didn’t have any link colors so I used this code /* unvisited link blue */
    a:link {
    Color: #196380;
    }

    /* visited link green */
    a:visited {
    color: #248f24;
    }

    /* mouse over link orange */
    a:hover {
    color: #ff3300;
    }

    /* selected link red*/
    a:active {
    color: #cc0000;
    }

    but it turned colors on for everything that is a link such as menu’s into a color.

    I only want the colors for linking.

    I would appreciate any help with this. Thanks

    • WPBeginner Support says

      Hi Joe,

      In your CSS, you didn’t define which areas should have links in these colors, which makes them apply to entire body. To figure out which areas you need to target, you will need to use the Inspect Tool to find out the CSS class used by your theme for the content block.

      Let’s suppose the content block in your theme has a css class site-content, you will use it in your CSS like this:

      .site-content a:link {
      color: #196380; 
      }  
      
      .site-content a:visited {
      color: #248f24;
      }
      
      .site-content a:active { 
      color: #cc0000;
      }  
      
      .site-content a:hover { 
      color: #ff3300;
      }
      

      Hope this helps :)

      Administrateur

  19. Rob says

    I love your site!

    Thanks for all the helpful articles.

    I have a question regarding my wordpress premium plan.

    I want to add the following script to my site.

    var refTagger = {
    settings: {
    bibleVersion: « NKJV »
    }

    Can I add this to the custom css?

    I don’t have the ability to access the header or footer in this plan

    Thanks,

    Rob

  20. Thomas says

    Hello,

    this feature isn’t active for the site admin on a multisite WordPress network.
    Do you think that activating it for site admin (with this plugin for example:) would create a security issue?

    Thank you!

      • Thomas says

        Hi,

        yes I know (I have already used the very good Simple Custom CSS plugin), but I would prefer to use the native function since it is implemented in WordPress.
        However, this function is only available for the network admin and not for the site admin on a multisite installation.
        The rights can be easily changed to allow site admin to add their own custom CSS in the customizer (with the native WP function) (see this plugin: http://www.wordpress.org/plugins/multisite-custom-css/), and I wonder if this would create a security issue (based on the assumption that I can’t trust site admin)?

        • WPBeginner Support says

          Hey Thomas,

          Sorry, we totally misunderstood your question :)

          We agree that will be a concern, this is why the feature is turned off. If you turn it on, then the users will be able to add unfiltered CSS. You should keep it switched off.

  21. Brice says

    I don’t know much about code so I’m just wondering if I make changes and click « save and publish », is there a way to get the original code back if I don’t like the changes or do I need to copy and save the original code in the event I want to restore it?

  22. Ruth Billheimer says

    This is probably really naive, I don’t know much about code, so bear with me.. In the customise additional css, can you put in different things? I mean I have already put something in there that will change some of the colours. Now I want to put in something that will change the width of the page. (I am getting these bits of code from very helpful people, I know nothing!)
    So will both of these things work? Or can you only change one thing? It doesn’t look like the page width has changed :(

  23. Jos Schuurmans says

    Hi there,

    It used to be possible to edit style.css from within WP admin, under the Appearance menu.

    On WP multisite it was through the network’s themes submenu. Has that feature been depricated?

    Cheers,
    Jos

  24. Judy says

    Great post, thanks!

    Can anybody help me with this? I did a small customization on my logo using CSS Hero. Then I’ve copied these exact 9 strings of code into my Simple Custom CSS plugin, after deactivating CSS Hero. I thought I could reproduce the same CSS Hero customization on my logo using Simple Custom CSS, but instead it’s not working.

    I refreshed the page and cleared the cache, but the customization still doesn’t take effect. Why’s that?

    Thanks,

    Judy

  25. Robin says

    This is all that is on my CSS Style Sheet.
    /*
    Welcome to custom CSS

    To learn how this works, see
    */

    Do I erase his and add my new font code? Help????

  26. Paul H. says

    OUTSTANDING PLUGIN!!!

    I spent much time trying to get the built in WP Editor to « style » my custom page, with no luck…

    I searched for a plugin to see if there was one and found yours… within minutes I’d installed your plugin and activated it, then input my CSS, clicked update and then refreshed my custom page… it’s perfect!

    A+++

  27. Ian says

    Hi Guys,

    I’ve installed the Simple custom CSS plugin & activated it. I have a table created on one of my webpages that I wanted to have a border around it.

    As a result, I have added the following code to my simple custom CSS plugin

    table {
    border: 2px solid black;
    }

    and updated the Custom CSS but nothing happened – I still don’t get any border on my webpage table.

    Any suggestions?

    Regards

    Ian

    • Molly Setzer says

      Hey Ian,

      It’s likely that you are not calling it by the correct css selector. Use the most defined selector to grab the element. For example, if your table has a class of « info » then calling it by the more specific table.info will help you reach the element. Check if it has more selectors in the html.

  28. Estee Peter says

    How do i add custom css via my existing specific website plugin

    this is the following code

    .mobileonly {
    display: none;
    }

    @media screen and (max-width: 480px) {
    .mobileonly {
    display: inline;
    }
    }

    .hidemobileonly {
    display: inline;
    }

    @media screen and (max-width: 480px) {
    .hidemobileonly {
    display: none;
    }
    }

  29. Gary Zielke says

    Does the Custom CSS plugin work on individual pages.
    i.e can I add style to a single page and not the whole theme?

    Thanks

  30. Joey says

    Thanks, I wish I realized this sooner because I’ve made all my css changes on the style.css file since I’m making the changes locally but are you saying that if for some reason Genesis decides to update the particular child theme I used I will lose those changes? I don’t know if I’ve ever seen them update their child themes although I’ve only been using Genesis for a few months so I suppose it is entirely possible they will update certain ones here and there. I think going forward I’ll make my changes in the plugin especially if the site is live.

    • suzie says

      Use the theme you like and create a ‘child theme’
      The child theme is then unique to your website.
      Make any changes only on your child theme.
      The theme designer may update their theme, but your changes will remain. (Depending on the designers update you may need to tweak your changes, but that’s unlikely).

  31. Rodney says

    Great article.

    I just wanted to add here. There’s a lot of option here specially sites running in WordPress, building/creating custom css is simple. Most wordpress themes usally support adding custom css without having to create or add additional plugins.

    I also agree, and the best option here is using a child theme instead.

    thanks

Laisser une réponse

Merci d'avoir choisi de laisser un commentaire. Veuillez garder à l'esprit que tous les commentaires sont modérés selon notre politique de commentaires, et votre adresse e-mail ne sera PAS publiée. Veuillez NE PAS utiliser de mots-clés dans le champ du nom. Ayons une conversation personnelle et significative.