Archive for the ‘CSS’ Category

HTML 5 Overview

Friday, August 20th, 2010

I have been doing some research into HTML 5 for work recently, so I thought that I would share some of my findings anyone who is interested. Look out front end web designers, this new version will give us the tools we need to create some great design! I am very happy with the possibility of endless possibilities with HTML. Just when I thought I knew most of the tags, elements, and attributes in HTML, here comes another version with a whole new set of tools that we can use to render design, content, and typography on the web. Right now there are several companies that make browsers that are working very hard to ensure that their product is compatible with as many elements and attributes of this new version of HTML.

One of the more interesting items I like with HTML 5 is the sectioning of content that it provides. It gives the web publisher the ability to have tags that define that particular area of a web page rather that just wrapping all content into DIVs and Spans. Some of these tags include but are not limited to:

SEO and HTML 5

Mentioned previously are  a few very basic new tags available that do not require any special programming ability. I believe that there will be a niche for organizing these tags to enhance SEO. This sectioning will change the way SEO is used across the web by giving authors the ability to specifically wrap their content in HTML elements that provide a specific definition of a particular section of a web page. Browsers will immediately know what part of the site is the navigation, or who the author is, or what time a business is open. There are endless creative opportunities to optimize your web page for bots and user agents. The <aside> tag is very interesting because now you can define the section of your site that provides advertising, archives, etc. so that user agents will understand that a certain part of your site is the advertising area, or a tag cloud, etc. These tags will be able to provide a more defined road map for where the user agents need to travel along your website. Currently, many developers use site maps to help user agents find their way, however the new tags will allow publishers to steer bots and user agents more precisely. I am only speculating what may happen with SEO and HTML 5, however I am certain that this will change everything. There are many pages out there that are beginning to use HTML to in the next few months there will be more data to analyze.

CSS3

CSS3 works hand in hand with HTML 5. The new features in the third version of CSS will give web publishers the ability to do a number of  different things than what they could in previous version of HTML. The most important CSS3 item that I think is worth mentioning is the ability to use almost any typeface that is available. At the moment there  are two types of typefaces that are able to be linked to a style sheet, True Type, and Open Type. I recommend using Open Type for anything and everything since they can be used on both Macs and Pcs without too many issues.  The only issue is that certain browsers will not use Open Type for font rendering, so there is a need for a True Type Font as well for downlaoding, if you want to provide cross browser support.

Here is a great article that discusses Cross Browser font issues with the new @font-face attribute: http://blog.themeforest.net/tutorials/how-to-achieve-cross-browser-font-face-support/

Here are some tags in CSS3 that are new:

Please return to my Blog in the future for more CSS3 and HTML 5 entries.

Thanks,

Scott

CSS Classes and IDs

Monday, May 3rd, 2010

CSS classes and IDs can be a very confusing subject indeed. The question seems to arise when do you use an ID and when do you use a class? For starters, for those of you that do not know what makes a style in CSS a class and what makes it an ID, the class always starts with a period. Classes and IDs are not intentionally saved for anything specific. Anything can either be a class or an ID, it just depends how you want to organize your CSS. Some web designers never use classes and only IDs, some designers only use IDs. By using both classes and IDs in an organized fashion, designers can really make their code flow well and make a site that is easier to change and adapt in the future.

.someClass {

}

The ID style type always startes with a number sign.

#someID {

}

So, when should I use a class over an ID or an ID over a class? In my opinion IDs are saved for those styles that are more or less for large unchanging items in your site that are at a higher level of importance such as headers, navigational, and footer DIVs. Containing DIVs are are a great place to use IDs also. The IDs act as the sound structure of the CSS, things that you would never want to change, or take great care in changing. Think of them as being part of a frame of a house, the plumbing, or the electrical box. These are things that you do not  want to change if at all possible down the road.

Classes are best suited for content styling that may have to be repeated several times. For example, a paragraphi style would be a good place for a class over an ID. Classes are also great for nesting. Nesting of styles is basically the act of placing a style within a style. Lets say you have a style called Heading1. This style might be a large red header that shows up on the top of pages. You might want to create a heading that is very similar to this style, however has a slightly different color. For example if you wanted to have a heading that was not as prominent yet had the same size and typeface (font). Creating a nested style would let you create a style based on another higher level style without having to write out all of the parameters again.

.heading1 {

font-family: verdana;

Size: 18px;

color: #cc0000;

line-height: 14px;

}

A nested style would look similar to this.

.heading p {

color: #663333;

}

You did not have to replace all of the style, only the color.

So how would you implement this in your code?

<div class="Heading1">Some Heading

<p>A different Colored heading</p>

</div>

Since you have already defined the div as a heading1, anything within the DIV under a paragraph tag will be a different color as stated above.

Anyways, this not only helps to lower the amount of lines in you CSS file, it also helps you create sub styles that are easy to manage.

Templates

The idea of having different classes and IDs that are nested are very helpful in creating templates. You could easily have a main tempalte set up and then several different other template styles that are based on your main template. Whole websites could look completely different if you have several different nested styles set up, based on your original template styles.

For example, let say you create a heading1 and you wanted three different options for users to choose from in your CMS.

.Heading1 {

font-family: Verdana;

font-size: 24px;

color: red;

}

.Heading1 template1

font-family: arial;

font-size: 36px;

color: blue;

}

.Heading1 template2

font-family: Times;

font-size: 36px;

color: Green;

}

You will notice that each of these are pretty different, however they could be the same place within the CSS layout of your template, so when displayed they would look totally different, however have the same structure that would not have to be changed. This is one of the beauties of CSS, the ability to create a style and then have several different options that all based on a higher level.

Are hiding H1 tags bad for SEO?

Thursday, November 12th, 2009

This is one of those questions that I have seen over and over. I have come up with my own methodologies of doing this, in fact, I did it on this blog at one time, however I have always found that if you are trying to hide something, Google and the other big engines will look at it as hidden. Google may also penalize you for this, since this is something that could likely be considered Black Hat. Don’t get me wrong, I wish that we could do this, especially since the Word Press H1 tag is in the header. This is a situation in my opinion where you need to use H1 as what it is designed for TEXT. This is one of the most important attributes in organic SEO, so why would we want to trick a browser that could black list you in some way, drop your rankings. My suggestion is to position the H1 text in a way that it looks like your brand instead of fighting against it. Use relative position to move your text so that it lays on top of a background image and looks as if it seamlessly sits in the design.

So, I want to know what YOU think!

CSS: How to Create a Basic Inline Style

Monday, November 2nd, 2009

One of the easiest ways to change the way a specific <div> <span> or paragraph tag’s looks on your web site is to change the style by doing it “inline”. Inline refers to editing the code directly in the line of line of the HTML, instead of updating an external style sheet, or a style sheet that is defined in the header of the page. This is something that I do not usually recommend, however there are instances that require this on the fly. An inline style will override a style that has already been established in the external style sheet or the header. One good example of this, is if you need to adjust the height of a specific <div> however do not need to update the style sheet. For example, you have an frame for an image that needs to be in a containing <div> that is 400 pixels tall.

In this example, we will simply define the height of a div with inline style.

&lt;div class="someDiv" style="height: 400px"&gt;

The “style” parameter, will begin the style attribute. After the quote marks, you can use any CSS value here, and as many as you like separated by a semi colon. Below, we will use multiple attributes.

&lt;div style="font-size: 24px; font-weight: bold; color: red;"&gt;Some Words You Have Written&lt;/div&gt;

Some Words You Have Written

As you can see it is very easy to add an inline style, just make sure that you do not make a habit of this, however use it when you need to.

MeasureIt for Firefox

Monday, August 10th, 2009

Ever wanted to know how many pixels wide something is on a web page. I used to find myself doing a print screen, pasting into my favorite editor and then measuring it using that application’s measuring device. I wanted to know how I could speed this up, because in my line of work it is necessary to know the measurement of elements on a web page. How could I accomplish this easily? I found a plug in that enables you to do this on the fly using Mozilla Firefox. This plug in is great, you just install it, then a small tool appears int he bottom left hand corner of your browser!

Example of the Firefox add on called MeasureIt

Example of the Firefox add on called MeasureIt

Just click on the tiny ruler icon and a cross-hairs will appear. Drag the cross-hairs over the desires area of measurement, and a measurement will appear.

Firefox MeasureIT add on in action!

Firefox MeasureIT add on in action!

After you are finished the measurement, just click the ESC key. Yes, it is that easy!

Click here to download this add on directly from the Mozilla add on site.

CSS text kerning for your web pages

Wednesday, July 22nd, 2009

Have you ever felt like you were limited in the things that you could do with your typography on a web page? I have, and before I knew what CSS was to apply a form of “kerning” to my web pages without having to create a custom text graphic. Custom graphical text is always going to look cooler, however for particular reasons you may not want to do a graphic for every time you create some text, such as a dynamic photo caption pulling from a database. Now with CSS3 becoming more browser compatible, the use of typography will begin to expand more and more.

The CSS parameter you want to use is called letter-spacing. Yes, it is that simple!

Anyways let begin. Lets say I want to have a caption for my photo that looks cool and well designed. The first photo caption is standard.

CSS Kerning tutorial

Our beautiful lake

Now Check this out!

CSS Kerning tutorial

Our beautiful lake

Doesn’t this look much better?

Anyways, here is the CSS
Take your text and wrap it in a <span> tag. This tag helps you apply a style to the text easily, however this is not the only place to use style. </span>

<span>Our Beautiful Lake</span>

Next add a style and the line spacing (int his example we are using Inline Styling, however the same styleing can be used in an external style sheet):
<span style=”letter-spacing: 5px”>Our Beautiful Lake</span>

The result is:  Our beautiful lake

It’s that easy! Hope this was helpful.

Again, there are many new features that are coming available in CSS3 that will enhance the ability of typographical design without having to create textual images and such. Please return to http://scottlassiter.com/blog in the future to learn more about CSS3 features.

Cropping an image on the web using CSS

Monday, April 20th, 2009

Ever had an image that you could not re-size, or did not want to re-size, however wanted to crop? Maybe the image was too large for your page or, you just wanted to show a small portion of the image. Using this technique you can also position text on top of the image, like a caption, without having to edit the image. This a very cool method to use, if  for  SEO purposed or to be reference the text in the HTML.

The intention is for you to use the CSS in the header of your document or in a linked Cascading Style Sheet (.css)

First lets start with an image as illustrated below:

pontiac_g6

I need to crop this image and I want to give it a caption directly on the photograph. For this particular instance I just need to show the front of the vehicle.

First I will start by creating a DIV contain for this:

<div><img src=”http://myserver/mycar.jpg”></div>

Above is a line of code that creates just a simple container. Next we need to create a class for the image for the CSS. You will actually use the class tag within the image tag to call to the CSS. The CSS class beloow will be added to your stylesheet.

.image {
border-width: 1px;
border-color: #ffffff;
border-style: solid;
width:225px;
height:70px;
background-position:50% 95%;
background-repeat:no-repeat;
}

In the CSS code above, I have created an image class with a 1 px border and and an area much small than the image. I have also told the background not to repeat itself.

Pontiac G6

Above you will see my cropped image with a title at the top in black. To make the image appear you HAVE to put in some kind of text for the image to show.This is what I used for the code:

<div class=”image” style=”background-image:url(http://myserver/mycar.jpg)”><div>Pontiac G6</div></div><br />

Notice that I had to use a little in-line CSS to make the image appear (background-image). This way, you do not have to put the background-image URL in your style sheet, in the case if you want to have several images cropped with a specific size using the .image tag as a reference. Also make sure to have the break behind the last DIV.

Now, how would I make the text in visible in a different position and in a different color? Start by creating a “title” class like we previously created the “image” class.

.title {
font-family: Arial, Gadget, sans-serif;
font-size: 14px;
font-weight: bold;
color:yellow;
position: relative;
top: 25px;
left: 30px;

}

Pontiac G6

Above you will see that I have positioned the text and have styled it to be a different font, color, and weight. By setting the position to Relative and adjusting the top and left, you can position your text to be anywhere within this DIV container.

Again, this is a case where we created a style with the CSS file so that we could create a “template” of sorts that we could reference again. The other method is to put all of the styling within a “style=” tag within the DIV.