Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 824065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:02:40+00:00 2026-05-15T03:02:40+00:00

As a CSS newbie I’m wondering if it’s recommended by professionals to repeat specific

  • 0

As a CSS newbie I’m wondering if it’s recommended by professionals to repeat specific style attributes and their not inherited but default properties for every relevant selector? For example, should I rather use

body {background:transparent none no-repeat; border:0 none transparent; margin:0; padding:0;}
img {background:transparent none no-repeat; border:0 none transparent; margin:0; outline:transparent none 0; padding:0;}
div#someID {background:transparent none no-repeat; border:0 none; margin:0 auto; padding:0; text-align:left; width:720px; ...}

or

body {background:transparent; border:0; margin:0; padding:0;}
img {background:transparent; border:0; margin:0; outline:0; padding:0;}
div#someID {background:transparent; border:0; margin:0 auto; padding:0; text-align:left; width:720px; ...}

or just what (I think) I really need

body {background:transparent; margin:0; padding:0;}
img {border:0; outline:0;}
div#someID {margin:0 auto; width:720px; ...}

If it’s best practice to go with the first or second one what do you think about defining a class like

.foo {background:transparent; border:0; margin:0; padding:0;}

and then applying it to every relevant selector:

<div id="someID" class="foo">...</div>

Yep, now I’m totally confused… so please advise! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:02:41+00:00Added an answer on May 15, 2026 at 3:02 am

    Your aim in writing CSS should be the readability and maintainability of your stylesheet. Usually that means writing as few rules as possible, a goal that is helped by using as many shortcuts as possible, and taking advantage of the CSS initial values and the browser stylesheet defaults that are reliable.

    (Occasionally you may want to duplicate rules a little because you’ve got two parts of the page that you want to style similarly by coincidence, and you want to split those styles into different sections of the stylesheet so you can manage the sets of rules in groups.)

    Not all browser stylesheet defaults are reliable, which is why people use CSS resets. (Although personally I find most of them much too heavyweight and intrusive. Most modern browsers agree on the important stuff, needing just a few hints here and there to fix particular sore points. The overhead of setting a dozen rules like margin: 0 on every element in the document just seems way over the top.)

    A lot of the properties in your example are the initial and/or default-stylesheet values anyway, so you gain nothing by including them. (border-width: 0 is not technically the initial value, but since border-style: none is, you won’t notice the difference.) Your rules would be much easier to cope with written minimally:

    body { margin: 0; }
    #someID { width: 720px; margin: 0 auto; }
    

    what do you think about defining a class like

    .foo {background:transparent; border:0; margin:0; padding:0;}
    

    Well, it depends what foo is. If you have many elements on the page that represent the same thing you should certainly mark them up with a class and style them all in the same way.

    But if you just want to apply some styles to a load of unrelated elements, you should target them separately (using , in the selector). Don’t pollute the content markup with style concerns by adding bogus classes like class="red_thing big_border".

    However as it stands, with those rules which are the same as the defaults for most elements including the <div>, .foo would be useless anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not a newbie to css and html, but totally not smart with php.
newbie question in css: I have the following style defined: TABLE.tabulardata th { font:
Hey all - simple CSS newbie question, but I can't seem to enter the
I'm a CSS newbie and was wondering if there is a benefit using em
The CSS rules visibility:hidden and display:none both result in the element not being visible.
The CSS syntax highlighting in vim is not entirely optimal. For example: div.special_class stops
I am a CSS newbie. Is there a tool that can help debug CSS
Firstly I plan to CSS to style pages (with fluid layouts) which are targetted
I'm a total newbie when it comes to CSS so I've pretty much given
I'm a relative newbie to web development. I know my HTML and CSS, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.