Relation / difference between HTML and CSS - html

I have used HTML in its basic form, and I mainly work on "server side" (of Enterprise application, mainly based in Java EE).
From what I understand, HTML is the "pages" which we see in an browser (that source code which a GUI developer writes and which a browser renders appropriately).
For example in an HTML tag, we write "h1" element, and the browser displays the text within as bold.
Now why there is any need of css? From what I am aware of, CSS is used to give "style" to a html page. The confusion that I have, doesn't HTML in itself able to give the style? what were the compelling reasons for creation of css?
Can anyone help me understand this in simple words.

The code that you put in your html to style it is actually CSS. HTML actually has some built in CSS. So really, you are using CSS when you do that. Also people like to connect a separate file for CSS in bigger projects. It looks more organized, and it easier to keep track of. It is also easier to code the CSS, because it is less messy and it seems like you have a bit more functionality. In conclusion, the code in the html that you are using to style with, is actually CSS, just built in. Also, I would highly recommend separating your stylesheet and HTML file(the stylesheet is CSS). If you need help, go to codecademy and create an account. Take the HTML and CSS lesson. I found this very useful and is where I learned most of my knowledge. I would highly recommend going to that site also. The site is also free.

Related

Basic styling for html5boilerplate

html5boilerplate is excellent, and I plan to use it. It basically reset browser styling, and provides some tools for optimizing page performance. Is there a styling/themes for html elements to jump start the development. similar to the themes listed at http://html5boilerplate.com/docs/#Home★html5-boilerplate-themes , but framework agnostic. In short, I am looking for styling for html elements (as a base for customization) to include in style.css file, right after the comment line that begins with 'Primary Styles'.
Thanks,
Bsr
You are basically looking for a stylesheet that magically gives a good style to a page without having to do anything? I doubt that exists, since the CSS is built on top of the HTML, and that would require knowing your HTML. There are probably examples of different layouts around the interwebs, but I don't think you are going to find anything similar to a "theme".

How to create pages using divs

Could someone suggest me any good beginners guide on how to create web pages from scratch (slice a psd) using divs. I have html and css knowledge but have never created any page from scratch in any way div/table/html5
Start by mimicking a simple page. This is called a "cleanroom" exercise, and is great for improving your HTML and CSS skills and actually making it possible to transfer design and layout ideas from your mind into code.
Here's how you do it:
Pick a page whose design you like and looks simple enough. For example, the logged out page at flickr.com.
Take a screenshot of it; do not look at the HTML/CSS code at all
Create a replica of it using your own HTML and CSS from scratch
You may use a color picker to find what colors they use
Try mimicking the fonts and distances manually, without looking at their rules; this will help you get a better understanding of page layout rules and typography rules.
Make sure your final HTML validates, preferably as XHTML 1.0 Strict (that's stricter than HTML5 and compatible with HTML5)
Also validate your CSS
Using the browser of your choice (e.g. Firefox 4 which is good at rendering things according to standards), check if your result is the same pixel-by-pixel.
Resize your website and see if it behaves the same as the original.
Ask a more experienced developer whether your HTML code is semantically correct. This will help you determine whether you've used the correct tags for the correct meaning.
This assignment will take you a long time the first time you do it, but if you're an experienced developer, it won't usually take more than a couple of minutes or up to an hour per page. It may become frustrating at times, but it's a great way to improve your skills. While doing it, make sure you look at references such as http://www.htmldog.com/ for the HTML/CSS language syntax.

What are the design patterns for HTML and CSS?

I know that is a very embracing question, but I have just started with Ruby on Rails, and still have a long way with CSS and HTML.
There are lots of books about CSS and HTML patterns, but I would like to know what is really applied to actual webpages.
For example, what's the best way of doing a simple webpage with a lateral menu, a logo on the top, and some text below?
Ok, it seems stupid, but there's lot of ways of doing that, or not ?
So, how can I learn this patterns and what are the real patterns ?
Would appreciate suggestions of books, articles, etc.
you can find some good css templates here:
http://www.csszengarden.com/
Actually in html and css there are not patterns in the oo sense.
I find this tutorial very useful:
Design and Code your first website
The nettuts website has a lot af very good free tutorials.
A very good book to begin is:
Head First HTML with CSS and XHTML
It varies from developer to developer. So I'll just tell you what I'm doing!
I'm actually following a very common pattern - separate ANY layout from the contents!
Into the HTML goes...
Text
<div/> containers with IDs to be layouted
And in the CSS goes...
Layout for the ID'd and class'ed <div/> layout containers
Colors, Background images
Fonts
It allows to rapidly change the whole page design without even touching the HTML! And it decreases both your server's traffic and the load time on the client pages, because the CSS file can be cached, since it does not change as much as the HTML does!
The CSS Zengarden nate posted is a very nice example of this pattern. The same unmodified HTML with dozens of CSS files with totally different looks!
This pattern also allows the same unmodified HTML to be displayed with automatically selected CSS files on huge displays, on small netbooks and on mobile devices. Can't be any better if you ask me!
You might want to check out some CSS libraries.
I don't personally like using them because I have ways that I like to do things and sometimes they aren't flexible enough for what I want to do. But since you're just starting out they might help you get something that looks good up really fast without having to worry about float drop bugs or margin collapsing or any other CSS quirks that are easy to hit but hard to recognize if you haven't seen them before.
An example would be the Yahoo User Interface (YUI) Grids CSS that will help you set up many different kinds of grid layouts. To find more, I would search for "css framework" or "css library".
Another YUI resource I think would be really useful for you would be their design pattern library, which documents different ways to display common interface items and gives you resources to go implement them. This can help make your interface look familiar to users and can keep you from feeling like you have to redesign a drop-down box or something.
The rule of thumb should be to do all design in CSS and HTML is just HTML without calls to design. That way, like referenced above, you can change design rapidly.
A good reference for how this works is the Zengarden CSS site at: http://www.csszengarden.com/
This is a site I used often as I learned the ins and outs of CSS design.

Is there a tool to take proper HTML + CSS and generate inline-styled HTML? Or: convert it to email compatible HTML

possible duplicate: What tools to automatically inline CSS style to create email HTML code ?
note from author: Oh yeh, definitely duplicate. Sorry.
In general, HTML emails do not support proper CSS techniques.
However, it's nice to develop in these techniques because it makes it a lot quicker to play around with changes etc. (I don't need to sell the benefits of CSS to you all!)
Is there a tool that will take lovely HTML and turn it into nasty email compatible HTML with all the styles extrapolated from the CSS files and placed inline?
Even though 100% compatibility cannot be achieved due to the numerous differences in email clients out there, a tool that helps the process would be very useful, even if it simply takes the CSS and inlines it.
Campaign Monitor have an excellent guide to CSS support in email clients as of 2008. It's very comprehensive.
There are no standards for "email compatible" CSS or HTML, so a tool to perform this task is unlikely to exist. Various client strip out different tags and attribues, especially web-based ones. A lot of it is trial and error. Trial and error is difficult to automate.
I imagine you could run the text of the page through a script that will discover CSS classes and ids and store the styles for them in an array, then go through and replace class="class" with style="style" and id="id" with style="style" etc. It would just be a matter of programming the thing.
Unfortunately, I don't know of any tools, but I would think this could be done using javascript (using jQuery, prototype, or other js framework), to rip through the rendered DOM and discover applied styles and create new HTML based on that
A good start would be to have a source div tag and a target div tag and see that the HTML in the target ends up looking like the source.
Just wrote blog post about converting "good" HTML/CSS into bad, but compatible HTML/inline CSS.
I personally use Premailer for this task, you can read more about it in my post: http://www.versapay.com/developer-blog/the-art-and-science-of-email-rendering-across-email-clients/
Yes, In my experience the best are:
http://premailer.dialect.ca/
http://beaker.mailchimp.com/inline-css
http://zurb.com/ink/inliner.php

How to get started creating CSS for given (dynamically generated) HTML?

The Separation of Layout and Content is the domain of CSS and HTML - so far well understood. Now about separating...
I'm looking for hints and Best Practices to get started with the task of providing a "skin" or "theme" for a content management system.
Background:
We are starting to embrace a Portal Server/Content Management System and are starting to change the look and feel to match our needs.
Our designer has so far mainly worked with full control over HTML and CSS, tweaking either one in order to get pixelperfect layout. With adoption of the cms there's a lot precreated HTML (very semantic, almost no tables :) that needs to be skinned with CSS and Images. Though it is possible to change the HTML fragments, I'd prefer to do so only as a last resort.
As this provides the challenge of "how to get started" my question is about any tipps how to proceed or articles that can help managing or organizing this task - e.g. best practices in designing, how to slice this task or what tool to use.
It seems bad practice to just save a dynamically generated page to disk and make changes locally. This would be somewhat ok for the CSS files but changes to HTML elements must be retrofitted to the fragments that they are generated from. I'd like to keep this out of the designer's realm if possible. Also, the thought of Dreamweaver (or any similar tool) making implicit tweaks to the HTML structure is frightening for me.
For the curious: The mentioned CMS/Portalserver is Liferay, but the question is really language- and tool-agnostic.
Edit: FireBug (as Josh suggested) is awesome for trying on-the-fly changes to css. Is there more - either in the area of tools or in-process and self-organization?
If you're looking for practical examples of separating style and content, then I'd suggestion the CSS Zen Garden. Trawling through the HTML and CSS is inspirational and enlightening and should help with what you're trying to do.
My #1 tip would be be to make everything as semantic as possible and use lots of classes and ids to hook your styles onto.
Usually, Whenever I am in a situation Like this, I bring up the page in FireFox, inspect the different elements using FireBug and see exactly what css is applied to them. THen I'l just modify the existing css until I get what I like. You can even play around in firebug and modify the CSS without "saving" those changes.
Have look at CSS Tidy, we normally use this to clean up the CSS and reorganise for development and production. However, I personally prefer writing HTML/CSS by hand before using this. It is just a matter of individual preference I guess.