Basic tips and tricks: 4.Css
Hello everybody, I'm back with another version of basic tips and tricks.
After having a talk with a client, about the basic on css, I thought it might be good to have an easy introduction.
So let’s give it a try. We'll talk about:
- Why would you use css?
- How to insert css in your html file
- How css is written
- Css on objects, classes and unique objects
- Basic css properties and there values
- The pseudo class
- Where to find good information on css
Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation (that is, the look and formatting) of a document written in a markup language.
CSS is designed primarily to enable the separation of document content (written in HTML or a similar markup language) from document presentation, including elements such as the colors, fonts, and layout.
enhance your css
Writing css code isn't that hard, it's easy, clean but can be a pain in the ass to keep it readable when you have hundreds or maybe thousands of lines of code.
When sticking to specific rules it can all be made a bit more readable:
- always use a reset of some sort
- alphabetize
- write comment
- consistency
- start in the right place
- Understanding Class and ID
- Power of li
- CSS Debugging Tools
read the full text to enhance your css code
5 Ways to Instantly Write Better CSS (click here )
20 Useful CSS Tips (click here)
layout inspiration
A lot of programmers seem to hate the layout part of the job. Well if you work in a big company you probably won’t do the two jobs, but in some cases, or when you work in a small company (ex 1-5 employees) you have to do them both (layout and programming). And for those guys, it isn’t always easy to have inspiration right away, well there is a solution.
Here are a few sites that have a huge portfolio with nice layout sites. You can grab the css in some cases, and that’s the interesting part of it.
Take a look at them.
cssmania
cssremix/
cssimport
designsnack
Anyone got a better idea to get inspiration? Feel free to add your way of working in the comments.
basic tips and tricks: 1. Basic HTML
There seems to be a big lack of knowledge in the field of basic web design, therefore I decided to write a step-by-step web design tutorial. Every post will be a new chapter in development; I will try to give you a fresh view on what really matters and is interesting for starting users. We'll start with the basics like tags in html and go on with CSS; the future will tell us how far we get. The point is to share my experience with you guys, not to teach you every detail, if you are completely fresh to HTML and CSS; you better take a look at w3schools first. (http://www.w3schools.com)
So let's start off with our first post: BASIC HTML
First off all, if you want to learn HTML and CSS, try not to use the design view of programs to often. It's very easy to create simple pages with those design views, but you won't learn the code, and that's the important stuff you need to know. So let's take a look at basic fresh html code generated by Dreamweaver:
<!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>Untitled Document</title> </head> <body> </body> </html>
So what is really important in this example?
As you can see, html is completely built up with tags and every tag is written inside the tag it is containing to. You can see that the head and body tag are within the html tag, because the html tag is the whole page and the header and body are in it.
The head tags are simply to give information like the name of the page (now ‘Untitled Document') and include the necessary files (that's for later). The real important one is the body tag because that is what the user will see. Whatever you will write within these tags, will be displayed on the screen of the person that visits your website.
So if we write <body>test</body> the user will get an empty, blank screen with test written on it. Easy, isn't it? So now you can write whatever you want in the page. The tricky part is the layout of the text.
Layout of a text is also done with the tags as they are written in the first example. So when you want to write for example this is bold this is italic and this is underlined, you will have to write this:
This is <b>bold</b> this is <i>italic</i> and this is <u>underlined</u>
As you can see every type of layout has its own specific layout tags b for bold, I for italic and u for underline. When using tags, be sure that you always close the tags just as in the example.
Like there are tags for text layout, there are also tags for line breaks and paragraphs. When you are writing long texts with paragraphs in it, always try to write your text within the <p></p> tags. Don't use 2 <br /> tags instead; this is a very often made mistake. This is for the simple reason that <br /> isn't the same as a paragraph, it doesn't react the same way for every user, a paragraph tag does. So use your <br /> tags wisely within the <p> tags like so:
This is a long text and when we go to a new line within the paragraph we use a line break So this will be displayed on a new line within the same paragraph This is a second paragraph that will be displayed
This will result in:
This is a long text and when we go to a new line within the paragraph we use a line break
So this will be displayed on a new line within the same paragraph
This is a second paragraph that will be displayed
The last thing for today is the headings which are used to display titles. Just like the paragraph tag you can use the heading tag: <h1></h1><h2></h2>. H stands for heading and the numbers are the scale that the heading is displayed in, 1 being the biggest and 6 being the smallest.
That was it for today my friends, this was the easiest part, in next lessons we will talk about topics like:
DIV vs. Tables
CSS and how to use it properly
debugging and testing
and much more
Tables: use or don’t use
When creating a more complex table the last few days, I noticed that it is very useful to create them with the different additional elements: tbody, thead, tfoot, col, th, td, etc…
In order to create a table in your webpage, it is not required to use these elements but when using css and trying to put a layout on a table, they are very handy.
For example you can, by using the display property, specify the function of all the elements:
- TABLE { display: table }
- TR { display: table-row }
- THEAD { display: table-header-group }
- TBODY { display: table-row-group }
- TFOOT { display: table-footer-group }
- COL { display: table-column }
- COLGROUP { display: table-column-group }
- TD, TH { display: table-cell }
- CAPTION { display: table-caption }
TFOOT will always be displayed as the bottom row of a table and most of the time contains totals.
THEAD contains the header information of a table.
Not really a very interesting post, but I just love it when using a bit more complex css on tables. It makes the tables easy to manage and they are tons more readable in code.
The thing me and my colleagues noticed is that tables aren’t very good for web design; they are created to display data and not a whole site or newsletter. A few years ago everybody started creating sites in tables because they were easy to set up, and looked great in a few hours. But the horrible time starts when you need to change layout after worth. In the most cases you’ll end up with a table that contains a table that contains another table. I guess you get the picture and that they are very difficult to manage. By experience we can tell that they are not very layout friendly and readability sucks.
We started using divs and with good css you can do anything.
Take a look at it, we recommend it.