CSS font style family color align, etc. H O W?

I think you’re just missing a few basic concepts of making HTML and CSS… of course that you have a picture in mind BEFORE you have the content on the page usually means (to me at least) your development process is BACKWARDS.

You’re also doing a number of things that from a compatibility standpoint and/or accessibility standpoint are bad practice. These include:

  1. having the first heading on a page being a h2 – first heading should be a h1, all other level headings being by definition SUBSECTIONS of that h1.

  2. You’re building a new site, there’s no reason for the loose tranny – transitional is for supporting old/outdated/half-assed coding techniques circa 1998, not building new sites.

  3. You aren’t grasping how nesting works, or the difference between block-level and inline-level (and the default display states therein).

  4. A media type on that CSS link wouldn’t hurt, since it’s doubtful you want to send this styling to print or other media types.

  5. It’s generally bad practice to set a width on BODY since it’s not well supported cross-browser. This is why MOST developers add a DIV around everything to set the width AND centering.

  6. You’ve got your LINK for the CSS AFTER </HEAD> and before </body> – in STRICT that would be invalid markup… generally LINK has NO business being used outside of <head></head>

  7. It’s generally a bad idea to change font-size without explicitly stating a new line-height… and as a rule I avoid setting the font-size on paragraphs and instead set a condensed font-rule on body – that way all ‘default text’ is set up once instead of having to restate it on EVERYTHING. Case in point, if you said font-family on body, you wouldn’t have to say it again on the numbered headings.

So, with that in mind…

The images will not center using MARGIN, because they are a special version of inline-level, which defaults to display:inline-block (or something similar). Inline-level elements do not obey margin, but do obey text-align. You want the behavior on those of block to use margin to center them – so display:block; will fix it.

As fellgall said, text-align only centers the content of the element within said element, and NOT in relation to the screen.

A quick fix would be to put margin:0 auto; on body and lose the two margins you have, but again I would avoid using body in that manner and instead add a DIV, set the width on the DIV and center that.

So first, let’s clean up the markup and modernize.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
	xmlns="http://www.w3.org/1999/xhtml"
	lang="en"
	xml:lang="en"
><head>

<meta
	http-equiv="Content-Type"
	content="text/html; charset=utf-8"
/>

<meta
	http-equiv="Content-Language"
	content="en"
/>

<link
	type="text/css"
	rel="stylesheet"
	href="screen.css"
	media="screen,projection,tv"
/>

<title>
	Coto De Caza Real Estate
</title>

</head><body>

<div id="pageWrapper">

	<h1>Coto de Caza Snapshot</h1>
 	<p>
 		Thirteen year average sale price chart and a linear pricing chart for Coto de Caza
 	</p>
	
	 <img src="Images/12yr_cdc_det.jpg" width="920" height="698" alt="CDC-Detached" /> 
	 <img src="Images/12yr_cdc_att.jpg" width="920" height="698" alt="CDC attached" />

<!-- #pageWrapper --></div>

</body></html>

#pageWrapper being where we’ll set the master width and centering.

In CSS, I also advise using a short reset – there are longer and shorter ones than the one I use, this one is the most reliable. Simple fact is not all browsers start out with the same default paddings/margins/borders and setting them all the same at the start simplifies things. Just avoid “resets” that are actually frameworks, wasting time setting things that are the same cross-browser just to some user preference. (See Reset Reloaded for an example of your typical bloated code that gives resets a bad name)

I’m also not clear exactly what you want that blinds image on – the center 960px wide content area (#pagewrapper) or the whole page? I’m leaving it on body for now… I’m also pulling the ‘fixed’ part as that not only makes scrolling painful for many users, it’s also unreliable cross-browser.

Also, if you have to resort to “…/” in your CSS url, there’s probably something wrong with how you are laying out your directory structure.

So the CSS I’d be using would probably end up like this:


/* null margins and padding to give good cross-browser baseline */
html,body,address,blockquote,div,
form,fieldset,caption,
h1,h2,h3,h4,h5,h6,
hr,ul,li,ol,ul,
table,tr,td,th,p,img {
	margin:0;
	padding:0;
}

img,fieldset {
	border:none;
}

body {
	/* 
		This text-align is to center #pagewrapper in IE 5.x, 
		which incorrectly ignores margin:auto
		
		If you don't care about IE 5.x anymore, you can pull it.
	*/
	text-align:center; 
	
	font:normal 85%/140% "trebuchet ms",arial,helvetica,sans-serif;
	background:#000 url(images/blinds1.png) top center;
}

#pageWrapper {
	width:95%;
	max-width:976px;
	min-width:752px;
	margin:0 auto;
}

* html #pageWrapper {
	/*
		IE6/earlier knows not the min/max-width,
		but we can fake it with an expression. First
		we declare a fixed width for when scripting
		is disabled/unavailable.
	*/
	width:752px;
	/*
		Then our expression
	*/
	width:expression(
		(document.body.clientWidth>1024) ? "976px"
			: ((document.body.clientWidth>800) ? "95%" : "752px")
	);
}

p {
	padding-bottom:1em;
	color:#FFF;
}

h1,h2,h3,h4 {
	color:#F1D32E;
	text-align:center;
}

img {
	display:block;
	margin:0 auto 1em;
}

… and yes, that’s a lot to take in all at once. Don’t get discouraged there’s a LOT to learn, and there is a LOT of work involved in even the simplest of layouts.

Which unfortunately is why it’s called work, and not “happy happy fun-time” :smiley:

A very succinct statement, and one that’s undeniably true, that illustrates just how bad the available tools are. Damn it, people, there shouldn’t be a lot of work involved in producing a fairly straighforward layout.

Error when looking at html page.

chartpages.css cannot be found.

Root Folder: D:/PWSInternetSite
Folder From Root: CSS
Folder From Root: Images

All html pages are in the root folder.
All css files are in the CSS folder.
All Images are in the Images folder.

I’ve used DW CS4’s “Site” “ManageSite”

All I can select is the root folder and the images folder. The CSS folder doesn’t appear to allow for verification that’s it’s there and in the root folder hierarchy.

Any ideas ?

Thanks Rick

What does your link to the CSS file look like? If your folder is called “CSS” (capitals) and you reference it with

<link type="text/css" media="all" rel="stylesheet" href="[COLOR="Red"]css[/COLOR]/chartpages.css">

(that is, “css” in lower case) the link won’t work.

Other than that, we are shooting blind here unless you show the code you are using.

And I still can’t determine how to center small paragraphs!

One step at a time please.

In css how do I align all of the text paragraphs on a page to center/justified, and how do I flag the paragraphs in the html file.

Just one item at a time.

Thanks. Rick

Well then how about completing the one step you asked about before? :stuck_out_tongue:

Is the CSS link issue resolved?

<mythbusters>Well there’s your problem.</mythbusters> DREAMWEAVER. As a dearly departed friend used to say, the only thing you can learn from Dreamweaver is how not to build a website.

Do yourself a favor, uninstall DW, burn your DW manuals, make microwave art out of the CD’s… Until your skills mature Dreamweaver is only going to get in the way of building your site and you can learn NOTHING good from ANY of it’s automatically added code or any of it’s templates; It’s ALL some of the worst rubbish on the Internet… and once your skills mature, it serves no purpose.

Excuse me as I channel the dead – <dan schulz>The only thing about Dreamweaver that can be considered professional grade tools are the people promoting it’s use!</dan schulz>

Get yourself a flat text editor like crimson, editplus, notepad++, win32pad, etc, etc… for working on the code, a free FTP client to upload with (filezilla as good as any) and for “preview” use the actual browsers…

That way you can keep track of all the associations and directories yourself (making sure the files are in their proper locations) instead of relying on some tool that takes that control out of your hands.

Here is what I have in my html page:

<div align="center"><img src="http://www.sitepoint.com/forums/images/cdc_chart.jpg" alt="Coto de Caza Valuation Chart" width="920" height="860" /> <br />

<img src="http://www.sitepoint.com/forums/images/12yr_cdc_att.jpg" alt="12 Year Average Sale Price Attached homes" width="920" height="860" /> <br />

<img src="http://www.sitepoint.com/forums/images/12yr_cdc_det.jpg" alt="12 Year Average Prices Detached Homes" width="920" height="860" /> <br /></div> 

It works perfectly, however, what I would like is to assign a DIV in my css page so I can use the DIV styling from there.

I have about 80 graphical charts, three to a page.

I know it’s simple but I can’t figure it out.

Thanks Rick

(ps. I keep reading all of your prior post as I am slowly beginning to make out some of the pieces.)

pss. yes the css issue is resolved. I’m also trying NotePad+++

This works fine in Chrome but not well in IE7.


HTML Page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Properties With Style, Inc.</title>
<link rel="stylesheet" type="text/css" href="testcss.css" />
<style type="text/css" media=all>

</style>

</head>

<body>

<h2>COTO DE CAZA</h2>

<h2>Coto De Caza 12 Year Average Sale Price Detached Homes</h2>

<p>Arguably the most eclectic collection of home styles and lifestyles. Set behind 24/7 guarded gates, Coto de Caza offers two excellent golf courses with many fairway home site communities and ultimate equestrian estates. The village is just as the namesake describes - a village, set among oak trees covered rolling hills with trails for equestrian, hiking, mountain bike riding or just strolling along with friends. There is no Mello Roos taxes in the Village! The sports park holds many activities throughout the year complete with baseball diamonds, sand pit volleyball courts and much more. Don't miss The Coto de Caza 4th of July  Parade.</p>

<div align="center"><img src="images/cdc_chart.jpg" alt="Coto de Caza Valuation Chart" width="920" height="860" /> <br />

<img src="images/12yr_cdc_att.jpg" alt="12 Year Average Sale Price Attached homes" width="920" height="860" /> <br />

<img src="images/12yr_cdc_det.jpg" alt="12 Year Average Prices Detached Homes" width="920" height="860" /> <br /></div>


</body>
</html>

CSS Page

CSS Page

@charset "utf-8";
/* CSS Document */
/*<style type="text/css">*/

body {
background-color:#000000;
background-image: url('images/redsquare.png');
}
	
p {font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size:1.4em; text-align:justified; color:#CCC; 
   margin-left: 20%;  margin-right: 20%;
   
   }

h1,h2,h3,h4,h5 {font:Tahoma, Geneva, sans-serif; color:#CCC;
	text-align:justified; color:#CCC; 
   	margin-left: 20%;  margin-right: 20%;
   }

In IE 7 the text is crunched in the center above the charts. In Chrome the text is aligned to the widths of the charts which look really well.

How can I clean this up?

I’m trying to set up as much of the styling as possible in the CSS page.

I don’t wish to proceed any further from here until I can get a better grasp alignment. How do I set alignment in the CSS page? Should I make a template as there will be many pages exactly the same with charts and descriptions?

Next. These charts (jpegs) are designed to a certain pixel width. If I resize them in the css or html page they will lose their quality.

How do I figure out my page layouts according to a given width, say 960px?

Thanks everyone. It’s getting a little more fun now!

Rick

There are several… problems with your new code.

  1. There is no such thing as an align attribute if you are working in modern code.

  2. even if the align attribute still existed, putting it on the DIV should have zero effect on it’s content. I think you meant to put it on the IMG.

  3. MOST of your problem I suspect comes from the 20% margins, which may or may not be based on font-size. As a rule of thumb, % + Margin == unreliable at best, broken at worst. % on margins and padding are based on font-size, NOT page width, thought that CAN vary from browser to browser

Do you have a picture of what you want it to look like? Do you want that text the same width as the image? If so, you shouldn’t be trying to scale the text with margin, you should have a parent wrapping ALL of that tho handle the desired width ONCE.

Some other advice, never trust the default line-height, if you change the font-size change line-height too – it’s just less headaches in the long run. Likewise the condensed font property can end up less code.

… and put each property on it’s own line, it’s easier to read than the continuous one line where you can’t tell where anything begins or ends, or at a glance what properties are being set.

IF I’m understanding what it is you are trying to do…

Markup:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
	xmlns="http://www.w3.org/1999/xhtml"
	lang="en"
	xml:lang="en"
><head>

<meta
	http-equiv="Content-Type"
	content="text/html; charset=utf-8"
/>

<meta
	http-equiv="Content-Language"
	content="en"
/>

<link
	type="text/css"
	rel="stylesheet"
	href="screen.css"
	media="screen,projection,tv"
/>

<title>
	Properties With Style, Inc.
</title>

</head><body>

<div id="pageWrapper">

	<h1>COTO DE CAZA</h1>

	<h2>Coto De Caza 12 Year Average Sale Price Detached Homes</h2>

	<p>
		Arguably the most eclectic collection of home styles and lifestyles. Set behind 24/7 guarded gates, Coto de Caza offers two excellent golf courses with many fairway home site communities and ultimate equestrian estates. The village is just as the namesake describes - a village, set among oak trees covered rolling hills with trails for equestrian, hiking, mountain bike riding or just strolling along with friends. There is no Mello Roos taxes in the Village! The sports park holds many activities throughout the year complete with baseball diamonds, sand pit volleyball courts and much more. Don't miss The Coto de Caza 4th of July  Parade.
	</p>
	
	<div class="plateImages">
		<img
			src="images/cdc_chart.jpg"
			alt="Coto de Caza Valuation Chart"
			width="920" height="860"
		/>
		<br />
		<img
			src="images/12yr_cdc_att.jpg"
			alt="12 Year Average Sale Price Attached homes"
			width="920" height="860"
		/>
		<br />
		<img
			src="images/12yr_cdc_det.jpg"
			alt="12 Year Average Prices Detached Homes"
			width="920" height="860"
		/>
	<!-- .plateImages --></div>
	
<!-- #pageWrapper --></div>	

</body></html>

CSS:


body {
	font:normal 140%/140% "trebuchet ms",helvetica,sans-serif;
	color:#CCC;
	background:#000 url(images/redsquare.png) top center; 
}

#pageWrapper {
	text-align:justified.
	width:60%; /* assuming you wanted % as in screen width and not fraction of screen size */
	min-width:920px; /* don't let it get narrower than the plates */
	margin:0 auto; /* center this div */
}

h1,h2,h3,h4,h5,h6 {
	font-family:tahoma,geneva,sans-serif;
}

.plateImages {
	text-align:center;
}

In going through to rewrite, I noticed a few other issues… trebuchet is a M$ core font, as is Arial, so arial would NEVER get called in your font stack. Unless there are spaces in a URL you don’t need to put it in quotes in CSS, if you are going to have the same properties (like color or text-align) on your content elements, put them on BODY instead of on each and every one of them (they will inherit), then only state where it’s different. Also, your stating only “font” when all you have for properties is the family will get ignored in many browsers… If you don’t want to change their sizes or line-heights you should declare font-family, not just “font”… If you are setting two or more font- properties, that’s when you use just “font”… as illustrated above.

… and before you ask:

font:normal 140%/140% “trebuchet ms”,helvetica,sans-serif;

When using the condensed font property you have to declare a weight/style or some older browsers ignore it, the first number is size, second number is line-height, then the stack. 90% of the time you declare a change in fonts, that’s the best way to do it.

Oh, and if you want to fix the width of the layout to 960px, just change that 60% I say above to 960px… Though that’s called a “fixed width layout” – something I generally do NOT advocate. As it is I put a min-width on it so that it wouldn’t shrink smaller than the images. I kind-of assumed you wanted 60% of screen width as saying 20% margin is one of the most common mistakes out there. If you actually wanted 0.2em as the side margins, well that’s a horse of a different color.

Thanks much deathshadow.

I like your markup style.

I’m going to go slow and start with what I see first.

I created a completely new html and css file based on your code. (copy & paste)

The three images are all the way at the left side of the screen.

The text<p></p> spans the entire screen width.

I have not changed a thing in your code.

Is this correct?

Exactly what is pagewrapper? Is that the main container or is body{} the main container?

Rick

I have attached a small .pdf file showing what I would like for my site page regarding charts.

It’s really quite simple.

Thanks.

Rick

oops. Typo. that period after ‘justify’ should be a semicolon… Guess that’s why I usually put these on my server instead of doing a drive-by post… and the property is justify not justified; shows how often I use it. (generally justify for screen is considered ‘bad’ for usability)

Properties With Style, Inc.

I believe is what you are trying to do (so far before that new pdf) not that I’d actually do a layout that way (again that 60% is a wild guess). I also wouldn’t use quite so large a default font (more like 85% than 140%)

As with all my examples the directory:
Index of /for_others/RSchreiber

is open for easy access to the bits and pieces.

Your new PDF makes things a bit trickier with the sidebar, but not horribly so. If I have time later I’ll slap together an example of that.

Is that supposed to be fixed width or fluid?