Question:
Site layout? JavaScript or CSS?
Venom
2011-09-08 15:06:17 UTC
I am trying to a site that is centered perfectly in the center. I know it can be done with CSS alone, and I have seen some sites I like that use it like:

http://www.plewto.com
and
http://www.csszengarden.com/ (Although I did find CSSzen using a smidgen of JavaScript)

Is this a good way to built the layout? Is CSS a good way to go? Or should I make it JavaScript in order to have it a bit more compatible with other browsers. I know Cross-Browser and backwards compatibility is a plus.

I am new to coding, but I would like to really see the pros and cons of both. I see other sites do not rely solely on CSS, so this may be a good marker to go by, correct?

Also, yes I know I will have to use CSS with JavaScript, I am just wanting to know if CSS alone is viable like the sites I have shown.
Five answers:
2011-09-09 12:17:20 UTC
You ARE missing the point. CSS is used for a site's layout/presentation. That and only that with a proper document type, proper use of syntax with the selected doctype and check of all coding errors for CSS/HTML will go a longer way to make your pages cross-browser compatible. NOT JavaScript!!! JS can be used to "sniff" out a browser being used and deliver a CSS file for that browser, but it is unnecessary! JS is dependent on users having it enabled for your site so the CSS file may never be selected.



Choosing Dimensions for Your Web Page Layout:



In Search of the Holy Grail: http://www.alistapart.com/articles/holygrail/

http://www.elated.com/articles/choosing-dimensions-for-your-web-page-layout/

How to create flexible sites quickly using standards like CSS and XHTML: http://www.ibm.com/developerworks/web/library/wa-rapid/



Care With Font Size: http://www.w3.org/QA/Tips/font-size

Websites Shouldn’t Look The Same Across Different Browsers: http://www.noupe.com/design/websites-shouldnt-look-the-same-across-different-browsers%E2%80%A6here-is-why.html



Cross-Browser CSS in Seconds with Prefixr: http://net.tutsplus.com/articles/news/cross-browser-css-in-seconds-with-prefixr/

It’s Not Responsive Web Building, It’s Responsive Web Design: http://www.getfinch.com/finch/entry/its-not-responsive-web-building-its-responsive-web-design/

Beginner’s Guide to Responsive Web Design: http://thinkvitamin.com/design/beginners-guide-to-responsive-web-design/



Why Validate?: http://validator.w3.org/docs/why.html

CSS Validator: http://jigsaw.w3.org/css-validator/



More...
Jeff R
2011-09-08 22:21:37 UTC
CSS is designed for site layout. If your using IE, try hitting the F12 key to bring up the Developer Tools. You can turn off all css on a page to see what it looks like.



JavaScript is used to give the user a better experience using the page. It allows a more 'Windows' like experience by allowing client side 'stuff' to happen without having to make round trips to the server.
Hex
2011-09-08 22:27:18 UTC
Venom you're missing the point of JavaScript and CSS.



If you want to center an HTML element on the page try

using...



.mainContainer {

width: 930px;

margin: 0px auto;

}



Basically you're creating a class called 'mainContainer'.

Then you're using two properties. In order to center the

element you must first specify a width, then using the

'margin' property you can set it to have automatic margins

for both the left and right side of the container.



Also. JavaScript is aimed towards scripting functionality

into your page, and CSS is used for styling the page.

If you're looking to get the best of both worlds I'd

recommend learning JavaScript from www.w3schools.com

then googleing jQuery.
koppe74
2011-09-08 22:25:54 UTC
CSS is certainly viable alone. But by adding JavaScript, and let these scripts change CSS-stylesheets/CSS-properties, you get Dynamic HTML (DHTML).



CSS is handled by pretty much all browsers... there are more incompatibility with JavaScript than with CSS.
TEDD
2011-09-08 22:59:26 UTC
Doing CSs with a bit of JavaScript is a bit more fundamental


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...