473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Setting intelligent, consistent CSS default values

12
It was suggested elsewhere by a moderator that it is a good practice to use "* {margin:0}" at the beginning of my style sheet to turn off the browser-dependent spacing. Presumably this is one step to getting consistent rendering of the output whether using IE or other browsers. Also I have tried to become consistent by using the following in my templates:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

When I do this I find that various things start to deteriorate. For example my paragraphs run together without spacing in between, lists deteriorate in inconsistent ways, etc.

My question is this: Can anyone post some of the standard CSS they use to recover the "normal" look of HTML (I've spent several hours trying to get back to where I started but it still doesn't look right to me). I'd like to believe that I'm not the first to experience this and would like to save a few more hours of fiddling.
Apr 4 '07 #1
8 4059
drhowarddrfine
7,435 Expert 4TB
You should set padding, also.
*{
margin:0;
padding:0;
}

Your doctype is the wrong one to use and it mixes html with xhtml. There is a sticky at the top of this forum but this is what you need:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" http://www.w3.org/TR/html4/strict.dtd">
<html>

You have no need for the transitional doctype except for older pages that use deprecated code. Try those two things and see what happens.
Apr 4 '07 #2
jpullam
12
OK, I did that. And looking at my test pages in Firefox, I still find that putting all margins and padding to zero results in paragraphs that are crammed together, lists that are incorrectly aligned, etc. (No surprise)

What I'm hoping is that someone has already come up with a set of "starter" values for things like <p> tags and lists and other normal elements that will approximate the default browser behaviour I had before doing this (but is now consistently implemented across IE and other platforms).

I have spent several hours fiddling with values and experimenting and I'm still not at all happy with the result. The bullet lists look lousy, there's space where there shouldn't be, etc.

I really would like to write proper HTML and CSS, but I could use a bit of help.
Apr 5 '07 #3
drhowarddrfine
7,435 Expert 4TB
The problem is that browsers sometimes have different default margins/padding so there is no way to get them consistent, hence the reason for setting everything to zero and adjusting each individual element. Lists are particularly troublesome because IE gets it wrong by using margins while everyone else uses padding due to their initial misuse of the box model.

There are other ways to do this. Google for "undo html" and "really undo html" but those will do pretty much the same thing and you will have to go in and set those values individually to what you want, mostly to get IE to work correctly.
Apr 5 '07 #4
jpullam
12
I understand the problem. But surely someone has a standard set of CSS they use after setting the margins and padding to zero.

I know that if I spend enough hours on this I can come up with one on my own. I'm just trying to use the spirit of a forum (sharing?) to get a decent starter set that someone else uses. Like I said above, I've already spent hours on this and still haven't satisfactorily returned some relatively simple HTML to the look it had back before I started this whole exercise. (For example, I haven't been able to get the second line of my bullets to indent properly, and I'm still struggling to separate inter-line spacing and intra-paragraph spacing values in paragraphs.)

I understand that if I use someone's starter set, I'll need to tweak it for each site, but I'd think the common stuff we all need, like the margins and spacing around paragraphs and lists would be similar.
Apr 5 '07 #5
drhowarddrfine
7,435 Expert 4TB
Although there are templates around, these are designed for one particular look, but, no, default values are what everyone uses and setting everything to zero is most common.
Apr 5 '07 #6
jpullam
12
I'm not trying to start a flame war here, but frankly, I really don't understand why you are so willing to give out CSS that causes a page to deteriorate but not to offer some to help me recover it. In fact your categorical statement might cause any readers who have one to avoid contributing; after all, it's not nice to disagree with the moderator.

Fortunately, I located another site that discusses this very issue and from there I was able to get some simple starter values that seem to have solved my problem. Of course I will need to do my own additions and changes, that goes without saying. But it has stepped up to the problem of good initial CSS values. The article that I found very helpful was here:

http://kurafire.net/log/archive/2005/07/26/starting-css-revisited
Apr 7 '07 #7
drhowarddrfine
7,435 Expert 4TB
Feel free to disagree with me as much as you want, as long as you do it respectfully.

The link you are referring to is actually the third site I would have pointed you to but thought my first two references above would have sufficed. Your link is but another variation of those two. So while you say I wasn't willing to give you what you wanted, in fact, you are reading about the same method. It's all good but using this is not for everyone.
Apr 7 '07 #8
I think that main problem here is that as a newcomer to CSS, you are not aware of how much variance you can have between styles, problems, solutions, and foundation. If you start to standardize your initial pages in accordance with someone else's standard sheet you are already limiting yourself.

As was said, you found one more example of how to do it.

The biggest hurdle that I needed to get over with CSS and standardization was that I needed to think outside the box to produce newer, more invigorating design and development...from no standards except my imagination and logic.
Jun 24 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: blu4899 | last post by:
Hi, The Xerces XML parser is reading external DTD references in DOCTYPEs by default, but is not doing anything with them because validation is turned off by default. This is documented in...
9
by: Adam | last post by:
Hey, I'm trying to write a script with two standard drop down boxes. One contains days one contains the month. I want to update the options in the days box everytime the month is changed......
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
1
by: CES | last post by:
All, Could someone please point me to a step by step resource on setting up a ..net Web Application on IIS. I'm having a problem setting up IIS to except a new Web Application. I'm deploying...
2
by: Jonathan Trevor | last post by:
Hi, For the last couple of releases of a product we're developing we've been running to very wierd behavior from IE and our ASP.NET web application which serves up various types of files and I'm...
1
by: Matt Tinson | last post by:
Hello I have a datagrid with a datetimepicker column in it, which is bound to a dataset (MyDataset). The column in the dataset set that is mapped to the datetimepicker is called MyOrderDate and...
6
by: Troels Arvin | last post by:
Hello, In the init-script contained in the RPMs downloadable from the PostgreSQL site (I checked the one for Fedora), an explicit locale is set before running initdb. - And the explicit locale...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
8
by: Andrus | last post by:
..NET 2 Winforms application. How to create new setting and set it default value in userSettings section of app.config file or overwrite existing setting value ? I found code below in this list...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.