CSS Styling approachSet cellpadding and cellspacing in CSS?Convert HTML + CSS to PDF with PHP?How do I give text or an image a transparent background using CSS?Is there a CSS parent selector?How to style a <select> dropdown with only CSS?When to use margin vs padding in CSSChange an HTML5 input's placeholder color with CSSHow do CSS triangles work?How do I vertically center text with CSS?Is it possible to apply CSS to half of a character?

How to write a macro that is braces sensitive?

Which models of the Boeing 737 are still in production?

Mathematical cryptic clues

If I cast Expeditious Retreat, can I Dash as a bonus action on the same turn?

What is the word for reserving something for yourself before others do?

Has the BBC provided arguments for saying Brexit being cancelled is unlikely?

Example of a continuous function that don't have a continuous extension

Why linear maps act like matrix multiplication?

Is the month field really deprecated?

The magic money tree problem

Type 1 Error & Type 2 Error's pregnancy test analogy: is it legit?

Theorems that impeded progress

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

What would happen to a modern skyscraper if it rains micro blackholes?

Why are weather verbs 曇る and 晴れる treated differently in this sentence?

How can bays and straits be determined in a procedurally generated map?

Explain the parameters before and after @ in the treminal

What is the difference between 元 (圓), 幣, and 金?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

How is it possible to have an ability score that is less than 3?

What defenses are there against being summoned by the Gate spell?

Can a German sentence have two subjects?

can i play a electric guitar through a bass amp?



CSS Styling approach


Set cellpadding and cellspacing in CSS?Convert HTML + CSS to PDF with PHP?How do I give text or an image a transparent background using CSS?Is there a CSS parent selector?How to style a <select> dropdown with only CSS?When to use margin vs padding in CSSChange an HTML5 input's placeholder color with CSSHow do CSS triangles work?How do I vertically center text with CSS?Is it possible to apply CSS to half of a character?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Which is the more preferred style of CSS styling in the industry?




  1. Create classes for each attribute (like bootstrap), then attach the classes in HTML. For example:



    HTML: <p class="text-white text-bold"> John Doe </p>



    CSS:



    .text-white
    color: white;



    .text-bold
    font-weight: bold;




  2. Add usually 1 class per html tag. For example:



    HTML: <p class="description"> John Doe </p>



    CSS:



    .description
    color: white;
    font-weight: bold;



Which is overall the better approach?










share|improve this question

















  • 1





    Both are bad, but this is too opinion based.

    – Alohci
    Mar 9 at 3:31

















0















Which is the more preferred style of CSS styling in the industry?




  1. Create classes for each attribute (like bootstrap), then attach the classes in HTML. For example:



    HTML: <p class="text-white text-bold"> John Doe </p>



    CSS:



    .text-white
    color: white;



    .text-bold
    font-weight: bold;




  2. Add usually 1 class per html tag. For example:



    HTML: <p class="description"> John Doe </p>



    CSS:



    .description
    color: white;
    font-weight: bold;



Which is overall the better approach?










share|improve this question

















  • 1





    Both are bad, but this is too opinion based.

    – Alohci
    Mar 9 at 3:31













0












0








0








Which is the more preferred style of CSS styling in the industry?




  1. Create classes for each attribute (like bootstrap), then attach the classes in HTML. For example:



    HTML: <p class="text-white text-bold"> John Doe </p>



    CSS:



    .text-white
    color: white;



    .text-bold
    font-weight: bold;




  2. Add usually 1 class per html tag. For example:



    HTML: <p class="description"> John Doe </p>



    CSS:



    .description
    color: white;
    font-weight: bold;



Which is overall the better approach?










share|improve this question














Which is the more preferred style of CSS styling in the industry?




  1. Create classes for each attribute (like bootstrap), then attach the classes in HTML. For example:



    HTML: <p class="text-white text-bold"> John Doe </p>



    CSS:



    .text-white
    color: white;



    .text-bold
    font-weight: bold;




  2. Add usually 1 class per html tag. For example:



    HTML: <p class="description"> John Doe </p>



    CSS:



    .description
    color: white;
    font-weight: bold;



Which is overall the better approach?







html css






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 9 at 3:17









DailyCoderDailyCoder

166




166







  • 1





    Both are bad, but this is too opinion based.

    – Alohci
    Mar 9 at 3:31












  • 1





    Both are bad, but this is too opinion based.

    – Alohci
    Mar 9 at 3:31







1




1





Both are bad, but this is too opinion based.

– Alohci
Mar 9 at 3:31





Both are bad, but this is too opinion based.

– Alohci
Mar 9 at 3:31












3 Answers
3






active

oldest

votes


















1














Based on my experience, I am usually doing the first approach. Reason for this is for code reusability, because you can still apply it to any elements that would be needing the same styling.



Always name your classes as generic as possible.



Example:



.hand cursor:pointer; 
.padding-5 padding:5px;
.padding-left-5 padding-left:5px;
.border-1 border:solid 1px #f00;
.corner-1 corner-radius: 3px;
.margin-auto margin: auto;
.bgcolor-1 background-color: #b2e8ff; /* light blue */
.bgcolor-2 background-color: #FFF3CD; /* light yellow */
.table-hover tr:hover background-color: #eaf6ff !important /* overide bootstrap's table hover */





share|improve this answer






























    1














    Don't do it like that. Having only one style in a class will get confusing it would more so than putting all the styles for a element in its tag as



    <div style="border:solid 1px #333; color:#0f0; etc;


    What I found is a better approach is to create a generic type group class as



    .boxStyle1
    border:solid 1px #333;
    color:#0f0;

    .fontStyle1
    font-family: Arial, ...;
    font-size:.9em;



    And using them in different elements such like



    <div class="boxStyle1 fontStyle1">


    Using the group style approach lets you apply the same theme for different elements depending on what look you want. This way its less confusing when you want to change the look of your site.






    share|improve this answer






























      1














      I learned something similar to the second method. You specify style class/id names indicated in the HTML tag, <p class="sample">...</p>, then outline those details in a separate CSS file:



      .sample 
      font-family:Arial;
      font-variant:small-caps;
      color:#FF0;
      text-align:center;



      One of the primary benefits is efficiency. With all of the style details in one file, it's loaded once for your site visitor and the information is available to render for every page of your website that they visit. Thus reducing the amount of time it takes for your pages to load and improving the user experience. It is also more efficient for you while you are coding your pages. Once you decide how you want your website to look, you can create all of the element styles and reference it as often as necessary, greatly reducing the time to create your site. (Note: this does not mean that you can not or should not have more than one CSS file.)



      There are occasions when you want to list more than one class/id style for an element: <div class="sample sample2"></div>. Sometimes it makes sense to do it, however, seperating each individual style into it's own class/id is superfluous. Learn to group everything for your class="sample" in your CSS .sample (class).



      The W3C, Mozilla, and the online courses offered through edX all support this method as well. Which should clearly indicate that it is the "industry standard".



      W3C Starting with HTML + CSS
      Mozilla's Introduction to CSS Layout
      edX's CSS Courses






      share|improve this answer























        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073658%2fcss-styling-approach%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        Based on my experience, I am usually doing the first approach. Reason for this is for code reusability, because you can still apply it to any elements that would be needing the same styling.



        Always name your classes as generic as possible.



        Example:



        .hand cursor:pointer; 
        .padding-5 padding:5px;
        .padding-left-5 padding-left:5px;
        .border-1 border:solid 1px #f00;
        .corner-1 corner-radius: 3px;
        .margin-auto margin: auto;
        .bgcolor-1 background-color: #b2e8ff; /* light blue */
        .bgcolor-2 background-color: #FFF3CD; /* light yellow */
        .table-hover tr:hover background-color: #eaf6ff !important /* overide bootstrap's table hover */





        share|improve this answer



























          1














          Based on my experience, I am usually doing the first approach. Reason for this is for code reusability, because you can still apply it to any elements that would be needing the same styling.



          Always name your classes as generic as possible.



          Example:



          .hand cursor:pointer; 
          .padding-5 padding:5px;
          .padding-left-5 padding-left:5px;
          .border-1 border:solid 1px #f00;
          .corner-1 corner-radius: 3px;
          .margin-auto margin: auto;
          .bgcolor-1 background-color: #b2e8ff; /* light blue */
          .bgcolor-2 background-color: #FFF3CD; /* light yellow */
          .table-hover tr:hover background-color: #eaf6ff !important /* overide bootstrap's table hover */





          share|improve this answer

























            1












            1








            1







            Based on my experience, I am usually doing the first approach. Reason for this is for code reusability, because you can still apply it to any elements that would be needing the same styling.



            Always name your classes as generic as possible.



            Example:



            .hand cursor:pointer; 
            .padding-5 padding:5px;
            .padding-left-5 padding-left:5px;
            .border-1 border:solid 1px #f00;
            .corner-1 corner-radius: 3px;
            .margin-auto margin: auto;
            .bgcolor-1 background-color: #b2e8ff; /* light blue */
            .bgcolor-2 background-color: #FFF3CD; /* light yellow */
            .table-hover tr:hover background-color: #eaf6ff !important /* overide bootstrap's table hover */





            share|improve this answer













            Based on my experience, I am usually doing the first approach. Reason for this is for code reusability, because you can still apply it to any elements that would be needing the same styling.



            Always name your classes as generic as possible.



            Example:



            .hand cursor:pointer; 
            .padding-5 padding:5px;
            .padding-left-5 padding-left:5px;
            .border-1 border:solid 1px #f00;
            .corner-1 corner-radius: 3px;
            .margin-auto margin: auto;
            .bgcolor-1 background-color: #b2e8ff; /* light blue */
            .bgcolor-2 background-color: #FFF3CD; /* light yellow */
            .table-hover tr:hover background-color: #eaf6ff !important /* overide bootstrap's table hover */






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 9 at 3:28









            kapitankapitan

            736411




            736411























                1














                Don't do it like that. Having only one style in a class will get confusing it would more so than putting all the styles for a element in its tag as



                <div style="border:solid 1px #333; color:#0f0; etc;


                What I found is a better approach is to create a generic type group class as



                .boxStyle1
                border:solid 1px #333;
                color:#0f0;

                .fontStyle1
                font-family: Arial, ...;
                font-size:.9em;



                And using them in different elements such like



                <div class="boxStyle1 fontStyle1">


                Using the group style approach lets you apply the same theme for different elements depending on what look you want. This way its less confusing when you want to change the look of your site.






                share|improve this answer



























                  1














                  Don't do it like that. Having only one style in a class will get confusing it would more so than putting all the styles for a element in its tag as



                  <div style="border:solid 1px #333; color:#0f0; etc;


                  What I found is a better approach is to create a generic type group class as



                  .boxStyle1
                  border:solid 1px #333;
                  color:#0f0;

                  .fontStyle1
                  font-family: Arial, ...;
                  font-size:.9em;



                  And using them in different elements such like



                  <div class="boxStyle1 fontStyle1">


                  Using the group style approach lets you apply the same theme for different elements depending on what look you want. This way its less confusing when you want to change the look of your site.






                  share|improve this answer

























                    1












                    1








                    1







                    Don't do it like that. Having only one style in a class will get confusing it would more so than putting all the styles for a element in its tag as



                    <div style="border:solid 1px #333; color:#0f0; etc;


                    What I found is a better approach is to create a generic type group class as



                    .boxStyle1
                    border:solid 1px #333;
                    color:#0f0;

                    .fontStyle1
                    font-family: Arial, ...;
                    font-size:.9em;



                    And using them in different elements such like



                    <div class="boxStyle1 fontStyle1">


                    Using the group style approach lets you apply the same theme for different elements depending on what look you want. This way its less confusing when you want to change the look of your site.






                    share|improve this answer













                    Don't do it like that. Having only one style in a class will get confusing it would more so than putting all the styles for a element in its tag as



                    <div style="border:solid 1px #333; color:#0f0; etc;


                    What I found is a better approach is to create a generic type group class as



                    .boxStyle1
                    border:solid 1px #333;
                    color:#0f0;

                    .fontStyle1
                    font-family: Arial, ...;
                    font-size:.9em;



                    And using them in different elements such like



                    <div class="boxStyle1 fontStyle1">


                    Using the group style approach lets you apply the same theme for different elements depending on what look you want. This way its less confusing when you want to change the look of your site.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 9 at 4:00









                    MickMick

                    7915




                    7915





















                        1














                        I learned something similar to the second method. You specify style class/id names indicated in the HTML tag, <p class="sample">...</p>, then outline those details in a separate CSS file:



                        .sample 
                        font-family:Arial;
                        font-variant:small-caps;
                        color:#FF0;
                        text-align:center;



                        One of the primary benefits is efficiency. With all of the style details in one file, it's loaded once for your site visitor and the information is available to render for every page of your website that they visit. Thus reducing the amount of time it takes for your pages to load and improving the user experience. It is also more efficient for you while you are coding your pages. Once you decide how you want your website to look, you can create all of the element styles and reference it as often as necessary, greatly reducing the time to create your site. (Note: this does not mean that you can not or should not have more than one CSS file.)



                        There are occasions when you want to list more than one class/id style for an element: <div class="sample sample2"></div>. Sometimes it makes sense to do it, however, seperating each individual style into it's own class/id is superfluous. Learn to group everything for your class="sample" in your CSS .sample (class).



                        The W3C, Mozilla, and the online courses offered through edX all support this method as well. Which should clearly indicate that it is the "industry standard".



                        W3C Starting with HTML + CSS
                        Mozilla's Introduction to CSS Layout
                        edX's CSS Courses






                        share|improve this answer



























                          1














                          I learned something similar to the second method. You specify style class/id names indicated in the HTML tag, <p class="sample">...</p>, then outline those details in a separate CSS file:



                          .sample 
                          font-family:Arial;
                          font-variant:small-caps;
                          color:#FF0;
                          text-align:center;



                          One of the primary benefits is efficiency. With all of the style details in one file, it's loaded once for your site visitor and the information is available to render for every page of your website that they visit. Thus reducing the amount of time it takes for your pages to load and improving the user experience. It is also more efficient for you while you are coding your pages. Once you decide how you want your website to look, you can create all of the element styles and reference it as often as necessary, greatly reducing the time to create your site. (Note: this does not mean that you can not or should not have more than one CSS file.)



                          There are occasions when you want to list more than one class/id style for an element: <div class="sample sample2"></div>. Sometimes it makes sense to do it, however, seperating each individual style into it's own class/id is superfluous. Learn to group everything for your class="sample" in your CSS .sample (class).



                          The W3C, Mozilla, and the online courses offered through edX all support this method as well. Which should clearly indicate that it is the "industry standard".



                          W3C Starting with HTML + CSS
                          Mozilla's Introduction to CSS Layout
                          edX's CSS Courses






                          share|improve this answer

























                            1












                            1








                            1







                            I learned something similar to the second method. You specify style class/id names indicated in the HTML tag, <p class="sample">...</p>, then outline those details in a separate CSS file:



                            .sample 
                            font-family:Arial;
                            font-variant:small-caps;
                            color:#FF0;
                            text-align:center;



                            One of the primary benefits is efficiency. With all of the style details in one file, it's loaded once for your site visitor and the information is available to render for every page of your website that they visit. Thus reducing the amount of time it takes for your pages to load and improving the user experience. It is also more efficient for you while you are coding your pages. Once you decide how you want your website to look, you can create all of the element styles and reference it as often as necessary, greatly reducing the time to create your site. (Note: this does not mean that you can not or should not have more than one CSS file.)



                            There are occasions when you want to list more than one class/id style for an element: <div class="sample sample2"></div>. Sometimes it makes sense to do it, however, seperating each individual style into it's own class/id is superfluous. Learn to group everything for your class="sample" in your CSS .sample (class).



                            The W3C, Mozilla, and the online courses offered through edX all support this method as well. Which should clearly indicate that it is the "industry standard".



                            W3C Starting with HTML + CSS
                            Mozilla's Introduction to CSS Layout
                            edX's CSS Courses






                            share|improve this answer













                            I learned something similar to the second method. You specify style class/id names indicated in the HTML tag, <p class="sample">...</p>, then outline those details in a separate CSS file:



                            .sample 
                            font-family:Arial;
                            font-variant:small-caps;
                            color:#FF0;
                            text-align:center;



                            One of the primary benefits is efficiency. With all of the style details in one file, it's loaded once for your site visitor and the information is available to render for every page of your website that they visit. Thus reducing the amount of time it takes for your pages to load and improving the user experience. It is also more efficient for you while you are coding your pages. Once you decide how you want your website to look, you can create all of the element styles and reference it as often as necessary, greatly reducing the time to create your site. (Note: this does not mean that you can not or should not have more than one CSS file.)



                            There are occasions when you want to list more than one class/id style for an element: <div class="sample sample2"></div>. Sometimes it makes sense to do it, however, seperating each individual style into it's own class/id is superfluous. Learn to group everything for your class="sample" in your CSS .sample (class).



                            The W3C, Mozilla, and the online courses offered through edX all support this method as well. Which should clearly indicate that it is the "industry standard".



                            W3C Starting with HTML + CSS
                            Mozilla's Introduction to CSS Layout
                            edX's CSS Courses







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 9 at 5:00









                            elbrantelbrant

                            526215




                            526215



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073658%2fcss-styling-approach%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

                                Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                                List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229