The CSS Best Practices to Follow and the Bad Habits to Avoid

The CSS Best Practices to Follow and the Bad Habits to Avoid

The CSS Best Practices to Follow and the Bad Habits to Avoid

The CSS Best Practices to Follow and the Bad Habits to Avoid.Making a well-managed set of CSS codes could be a problem. As expertise evolves, it’s not likely simple to say for those who’re doing the fitting CSS finest practices otherwise you’re simply messing up the code and compromising the standard of your web site on totally different browsers.

CSS Finest Practices

Via apply, it's best to have the ability to keep away from CSS errors. So, to provide you a information on the dos and dont’s when writing CSS codes, we listed beneath the CSS practices to comply with in addition to the unhealthy habits to keep away from. So, prepare and let’s get began.

Use CSS Reset

Browser inconsistencies are one of many largest issues of front-end growth these days. Kinds like margins, paddings, line heights, headings, font sizes and so forth might look totally different on totally different browsers. The objective of a reset type sheet is to cut back browser inconsistencies by offering basic types that may be edited and prolonged.

One of many nice examples for a reset CSS stylesheet is normalize.css, a contemporary HTML5 CSS reset. All you must do is embody it earlier than your personal type definitions in your HTML file beneath the Head part. In any other case, these types will override your personal type definitions.

Present Type Sheet Info

Put a Title, Creator, Tags, Description, URL info and so forth in your stylesheet. It will give the consumer/developer a reference particular person to contact at any time when they want assist relating to your creation.

Arrange Parts on the Stylesheet from High to Backside

Often for learners, they put the weather on the stylesheet based on what they need to put first. However this isn't an excellent apply for CSS code construction because it gives you a tough time discovering CSS code components on the stylesheet. Ordering them from inclusive types (comparable to physique, H1, p, a and the likes) adopted by a header to a footer will make loads of sense.

Shrink CSS file measurement with CSS Compressors

It’s actually an incredible thought to shrink the CSS file measurement as it can take away white areas, line breaks and take away redundant CSS types. Via this, you may assist browsers to hurry up the loading of your CSS codes. Utilizing instruments like CSS Compressor and CSS Compressor & Minifier could make this occur.

Group IDs and Lessons That Fall beneath the Identical Component

When you have a component that incorporates totally different IDs and courses, you would possibly need to group them to make them look organized and straightforward to seek out so searching for errors wouldn't take time.

For instance, you might have a category container that incorporates a div tag that has an ID of emblem and one other div tag that has an ID of icons.

Use Annotations/Feedback to Determine a Set of CSS

One other finest apply for CSS coding is placing a touch upon every group of CSS. It will make it simple so that you can search for particular teams of CSS as soon as you bought in to some CSS errors.

Utilizing correct naming conventions on IDs and courses will make loads of sense to your work. It will assist your work simpler and quicker in case you'll want to add components or redesign a web site.

As an example, placing a category of title-red won't make sense whenever you change the colour of the title so why not simply put title as a substitute. All the time title your components correctly based mostly on their use not on their properties comparable to what coloration or font measurement the ingredient have.

Use Hex Code as a substitute of Identify Shade

Based on a efficiency take a look at run by Sean Connon, Senior Net Developer at Alien Creations, Inc, hex codes appears to be simply barely quicker on 4/5 runs. Try the take a look at efficiency right here. Due to this fact, we advocate utilizing hex codes fairly than title colours.

Use CSS Vendor Prefixed

If you're conscious of the brand new options of CSS3, you need to additionally know that every browser has its personal specification in the case of a particular type. That’s why browser prefixes are getting used to make it possible for the browser helps the precise options/type you need to use.

Many designers and builders are having an error with this straightforward matter as a result of they forgot so as to add vendor prefixes to focus on particular browsers.

Validate Your CSS

Utilizing W3C free CSS Validator will let in case your CSS code was correctly structured. One other advantage of utilizing it's it might probably level you the error in your stylesheet, thus, saving you extra time on troubleshooting it manually.

Unhealthy Habits to Keep away from

Creating Redundant CSS
Utilizing types repeatedly for particular components will not be an excellent apply. It’s essential that you simply clear your code and take away redundant types. For instance, when you've got a paragraph tag and span tag that has the identical font measurement and coloration, you would possibly simply group them utilizing a comma.

Mixing Tag Names with ID or Class Identify

Including tag title to an ID or Class Identify will not be an excellent apply since it might decelerate the matching course of unnecessarily.

Try the code beneath.

Targetting Margin and Padding Positions Individually

Utilizing separate CSS codes to focus on margin or padding both on prime, left, proper or backside will not be a good suggestion. Shrinking your code and mixing it in a single line will make your code extra readable and makes the loading of the browsers quicker.


For instance, you might have a div id of container and also you goal all of the positions’ margin individually. See the code beneath.

Utilizing Underscores on ID or Class Identify

Utilizing underscores would possibly provide you with pointless outcomes on outdated browsers. It's extremely advisable to make use of hyphens.

Remaining Phrases

All through this text, I supplied you some methods and pointers on find out how to write a greater CSS code and what errors to keep away from. Holding these guidelines whilst you’re coding will enable you implement clear codes and stop you from having errors sooner or later. Ensure you validate your CSS code utilizing W3C CSS Validator for a high quality and error-free CSS code.

Now let’s take a look at some nice strategies that you simply wont have the ability to do with out.

Superb CSS3 Strategies You Can’t reside With out

CSS3, together with HTML5, is rapidly shaping as much as be one of the crucial thrilling and helpful Net applied sciences in years. On this part, I shall be explaining among the new graphics-rich strategies and properties obtainable with CSS3. You'll study what's prone to be authorized as a part of the ultimate spec, what continues to be a work-in-progress, and find out how to take care of cross-browser incompatibilities and lack of assist in older browsers.

Introduction to CSS3

CSS3 is a group of modules that reach the earlier CSS2 specification that everyone knows and love. Many of the graphics results mentioned on this article come from the Backgrounds & Borders module. There are a variety of different additions in CSS3, a few of that are extra layout-focused, others allow methods of coping with content material styling that beforehand required server-side HTML era or JavaScript.

The essential factor to recollect is that CSS3 continues to be a work-in-progress, so simply because among the newest browsers assist these options doesn’t imply that (a) it's best to anticipate all browsers to assist these options quickly, and that (b) you received’t have to vary the way you do issues afterward as soon as CSS3 turns into a full fledged customary.

What Used to Require Photos No Longer Does

The annoying drawback of getting to avoid wasting out dozens of particular picture slices simply to create a pleasant button or field type is solved with CSS3. Utilizing a number of new properties, most of the widespread graphical results we designers prefer to make use of regularly are simple to create proper within the code. These embody (click on every picture for demo & supply code):


Lately, designers have been simply beginning to get used to the truth that you may simply add shadows behind textual content. Web Explorer doesn’t but assist the text-shadow property, however Safari and Firefox have for a while. However what’s actually thrilling is now you may add drop-shadows to containers and controls utilizing the box-shadow property. The syntax for box-shadow is far the identical as text-shadow, which we describe beneath.


Wow! That's all performed with CSS, no photos required. Simply so that you understand how briskly issues are growing, CSS3 doesn’t truly specify a regular syntax for gradients but, so at present there's one syntax utilized by WebKit (Safari, Chrome, and many others.) and one other utilized by Gecko (Firefox). We'll discover each approaches on this article.

Borders with Rounded Corners

CSS has allowed a number of totally different border types (double, inset, dotted, and many others.) for a while, however now with CSS3 we now have the power so as to add a border radius to some or all corners. Sure, rounded corners are actually potential with out resorting to loopy JavaScript hacks or photos! One other a part of the CSS3 specification is border photos, which can also be fascinating. It’s a fairly sophisticated approach all by itself, so I'll save that dialogue for one more time. You may learn extra in regards to the spec on the W3C.

Learn how to Type Containers

A very good mindset to make use of when utilizing the most recent CSS3 strategies is first to seek out a suitable baseline type that's supported by incompatible browsers. We’ll cowl some ideas about older browsers or IE assist later on this article, however the thought right here is to type a field or web page ingredient with out utilizing shadows, rounded corners, gradients, and many others. and see if you're fairly pleased with the end result. If it appears to be like respectable, then you may go forward and add all the great eye sweet with the data that if somebody is utilizing a browser with out the required CSS3 assist, they’ll nonetheless have an inexpensive expertise.

For right this moment’s instance, we’re going to by means of three levels so as to add in our particular types.

Begin with the Baseline

This CSS code will get us began. Create a div and enter in some textual content, and also you’ll see a fundamental field look.

Add Rounded Corners

As with most of those properties, we now have to keep up multiple syntax to assist a number of browsers (an actual disadvantage at present). Since I develop first in Safari on the Mac, I’ll begin with the WebKit model.

When in any respect potential, at all times add the model with none prefix. That approach you’re future proofing your type sheet in anticipation of the CSS3 ultimate customary.

If you wish to have further management over the radius of every nook, use the border-[top-left|bottom-right|etc.]-radius syntax. Word that at present, the Gecko model is barely totally different: -moz-border-radius-topleft, and many others..

Add a Drop Shadow

Now, we’re going so as to add the drop shadow. For those who’ve ever used the text-shadow property earlier than, this syntax will look acquainted.

Now right here you’ll discover I’m not utilizing typical hex codes for the colours however am utilizing the brand new rgba syntax. The primary three integers are the anticipated 0-255 vary of colours values, however the final one is a decimal quantity from 0.Zero to 1.Zero that represents the alpha worth (actually the opacity of the colour). The power to specify semi-transparent colours is actually welcome and permits us to create shadows that work properly on totally different backgrounds.

Once more, don’t neglect the choice variations:

Including a Gradient Fill

OK, that is the place issues are going to get difficult. The CSS3 spec for gradients is so new and undefined that there’s a very totally different syntax whether or not you’re speaking about WebKit or Gecko. I needed to spend a while going forwards and backwards between BBEdit and Safari to get it good, after which after I converted to Firefox, it took one other whereas earlier than I may determine find out how to duplicate my outcomes.

Gradients will be utilized to a couple widespread properties. Often you’ll need to use background. Right here’s the WebKit syntax:

For every color-stop, you need to use a share or a place worth (px, and many others.). I feel share is good as a result of it can scale with the field.

The Gecko syntax is totally different in fairly complicated methods, however requires much less typing:

I like to recommend beginning with the background selector for the strong coloration, then do the WebKit model, then do the Gecko model, for a complete of three background selectors. Browsers will go down the listing and use the one which they perceive.

Bonus Function: gradients on prime of photos!

As you may see, the ultimate product appears to be like very nice. You may even stack a number of containers on one another and see how the shadow results and corners are drawn. However then I had an thought. I’d heard that CSS3 helps a number of backgrounds, so may I truly create a gradient with alpha transparency on prime of a background picture? The reply is: sure.

The bottom line is to specify the WebKit model with the gradient, adopted by a comma, adopted by the url to the picture. After which try this over again with the Gecko model. That gives us with a ravishing “shine” impact on the prime of the field rendered instantly on the picture. With CSS3, you received’t have to fret about height-related picture tiling points for glows or shadows once more!

Styling Varieties

Type types will be difficult as browsers generally received’t render controls styled by CSS (they proceed utilizing the native OS’s UI components). Or they use among the selectors and ignore others. Typically, your finest wager is to stay with textual content fields and buttons, and use Javascript-based customized controls for drop-downs, radio buttons, verify containers, and many others.

Right here’s an instance of a few kind components styled utilizing CSS3:

What About Older Browsers?

The important thing with supporting older browsers or significantly Web Explorer is to decide on your battles rigorously. Some designers will determine they want each consumer’s expertise to be top-notch and so will eschew nearly all CSS3 results in lieu of utilizing photos as earlier than. Different designers could also be so gung-ho about CSS3 that they neglect that many customers won't expertise that nice of a visible design.

What I like to recommend is to attempt as exhausting as you may to create components utilizing customary CSS2 syntax first. For those who get to a suitable place, then add the CSS3 results you need. For those who don’t discover the baseline acceptable, then you definately’ll have to go the old-school approach. For those who undergo this thought course of with each ingredient individually, then you definately’ll most likely find yourself with a website design that has some components performed old-school for max compatibility, and different components (maybe much less important ones) spiffied up for the most recent CSS3 browsers.

What doesn’t make sense is to spend time creating image-based variations, then creating different CSS3 variations. Sure, serving two totally different variations relying on the consumer’s browser may save a small quantity of bandwidth, however I don’t see it as being well worth the effort. Go together with one model or the opposite and keep on with that.

As we converse on find out how to write higher code, we're introducing you with one useful gizmo. Prepared? Alright!

Net Service Evaluate: CSS Lint – Serving to You Code Higher

Coding is one thing that takes time to study and novice builders may not use the perfect practices when changing net interfaces from a Photoshop file into a totally purposeful site. It might be actually good to have entry to an expertise programmer, however not all people can afford to rent one or is aware of somebody that's with spare time.

So that you would possibly ask your self what to do to enhance the code earlier than delivering an online web page. Properly, fortunate you, there's a instrument on the market which I'll assessment for you right this moment. The instrument is known as CSS Lint, it's completely free and I positively advocate making an attempt it and see what you may get out of it. The distinction between an excellent and an incredible programmer is all within the small particulars CSS Lint can repair for you – or, a minimum of, can inform you to repair them and why.

CSS Lint is an open supply software that checks your code syntax and, based on the most recent net requirements, offers you a listing of errors it noticed in your CSS code. It's much like the W3C Validator, solely it offers you higher descriptions of your points and affords options about find out how to remedy them. The instrument may be very simple to make use of. The one factor it's important to do is paste the supply code and select the principles you need to be enforced (and there are many them). CSS Lint will begin analyzing your code instantly after you hit the lint button and it'll not take an excessive amount of time till you will note a full preview of how good your code is.

The principles

As mentioned earlier than, you may select your code to be checked by sure guidelines and I gives you a listing with all the principles you may select from.

1. Errors

Watch out for damaged field sizing.
Require properties acceptable for show.
Disallow duplicate properties.
Disallow empty guidelines.
Require use of identified properties

2. Compatibility

Disallow adjoining courses.
Disallow box-sizing.
Require suitable vendor prefixes.
Require all gradient definitions.
Disallow unfavourable text-indent.
Require customary property with vendor prefix.
Require fallback colours.

3. Efficiency

Don’t use too many net fonts.
Disallow @import.
Disallow duplicate background photos (new function)
Disallow selectors that appear to be regexs.
Disallow common selector.
Disallow models for Zero values.
Disallow overqualified components.
Require shorthand properties.

4. Maintainability and duplication

Disallow too many floats.
Don’t use too many font sizes.
Disallow IDs in selectors.
Disallow !essential.

5. Accessibility

Disallow define: none.


Disallow certified headings.
Heading ought to solely be outlined as soon as
The nice half about any of those guidelines is that CSS Lint offers you a full rationalization of every of them and, in many of the instances, suggestions on find out how to enhance your code and maintain the identical capabilities, however keep away from the precise mistake you made.

All these guidelines positively make sense, however there is no such thing as a time to check out all of them, so I'll select an important and provide you with a proof about why it’s a mistake to make use of them, and in addition some recommendations on find out how to change them with legitimate code. That is solely to provide you a preview of the instrument, you may clearly dig into it extra later.

Disallow duplicate properties

A couple of years in the past assigning the identical property to a container was a mistake, though it isn't thought of one right this moment. In the present day that is used as a option to take care of various ranges of browser assist for CSS properties. There are browsers on the market which assist RGBA colours and there are some that don't, so a snippet like the next one could be accepted:

. container background: #000; background: rgba (255, 255, 255, 0.5);

Furthermore, the next strains are additionally OK:

. container

Nonetheless, this isn't accepted and is places up a warning when the 2 properties are separated by one other totally different one or when the properties have the identical worth:



.container border: 1px strong black; coloration: purple; border: 1px strong black;

Require use of identified properties

As an increasing number of properties are accepted in a CSS file, this rule makes positive you don’t have any typos in your code. It's like spelling verify in Microsoft Phrase. This rule checks every property title and makes positive it's a identified CSS property. If there's a vendor-prefixed property (those starting with a -), they're ignored by the instrument, as a result of they could add in their very own properties. A standard CSS validator would warn when such a property is used (-moz-border-radius sound acquainted?), as a result of it doesn’t acknowledge the title, however CSS Lint doesn’t.

a could be accepted, however a colr: purple; could be displayed as a warning, as a result of the property colr doesn't exist. The next snippet: a wouldn't be displayed as a warning.

Don’t use too many net fonts

Utilizing too many net fonts is clearly unhealthy approach, not solely from a design perspective, but additionally from an accessibility and value viewpoint. An online web page that has to load multiple (most two) net fonts at each refresh goes to load very slowly and we all know how this impacts the consumer expertise on a website.

The instrument searches for the favored @font-face property and warns you when there are greater than 5 of them. Nonetheless, I personally don’t advocate you utilize multiple and, for those who can, attempt to keep away from utilizing them in any respect.

Disallow too many floats

The float property is used to realize a columnar format in CSS. A few of us have been thought we now have to make use of as many floats as potential to make sure the whole lot stays in place, however this isn't the case anymore. In the present day there are many grid techniques on the market which you'll obtain and they don't have an extra of this property. They're additionally made by professional builders and wouldn't have usability flaws. The 960 Grid System and The Grid System are two unimaginable grid turbines and I like to recommend you verify them for those who haven’t already.

Furthermore, utilizing one in every of these grid techniques will lower the quantity of code it's important to write your self, which is able to enable you ship the site quicker and make the ultimate product higher.

CSS Lint warns you when there are greater than 10 floats used (which is one thing many of the designers already use once they create the essential format). Analyzes have been made and it appears the grid techniques enhance site efficiency (supply), so why not reap the benefits of them?

Don’t use too many font-size declarations

In case your web site is well-organized, then it most likely has a small set of font sizes. Nonetheless, many designers choose to make use of a clearly seen hierarchy and do that by enjoying with the font sizes. Properly, this may not be an issue both if builders would code it correctly. As an alternative of utilizing font-size 15 occasions, outline three courses and use every one in every of them 5 occasions. To higher illustrate, check out the code beneath:

This fashion, as a substitute of declaring the scale of the font 15 occasions, simply level the container to a category. That is identified to be a lot quicker and to enhance the loading pace of your net web page. If there are greater than 10 font-size properties utilized in your CSS file, this instrument will present you a warning and an outline of the difficulty.

Disallow !essential

The !essential property is used to extend the specificity of a given property worth. If an online web page has many situations of this property, it's a clear signal that the developer makes use of it as a result of he has issues styling the web page successfully. Due to this fact, CSS Lint shows a warning when the !essential property is used.

Heading needs to be outlined solely as soon as

The heading is an Object-Oriented CSS (OOCSS) which works by defining sure objects that can be utilized to put a selected object anyplace on an online web page and show the identical. For instance, the heading components (h1 to h6) are built-in objects and will look the identical wherever they seem. This implies builders should not allowed to outline the identical ingredient a number of occasions.

The next code shows as a warning:

h3 font-weight: regular;

.field h3 font-weight: daring;

As you may see, the h3 has been outlined twice, as soon as for basic use and as soon as when used along with the category known as field. This isn't allowed! Nonetheless, headings will be outlined greater than as soon as when the hover property is used

CSS Lint is nothing greater than a instrument

The underside line is that CSS Lint needs to be taken as what it's – a instrument. Which means no developer ought to code like this instrument desires solely as a result of it says so. There are some guidelines that builders may not agree with (just like the controversial OOCSS guidelines) and no one forces you to make use of this instrument as a Bible. CSS Lint ought to solely be a instrument that will help you if you wish to know the place you may enhance. None of us like to seek out out that we now have points in the best way we code – so a few of us would possibly reject it.

So, the conclusion?

Despite the fact that there are some points with it, I feel CSS Lint is a instrument it's best to begin utilizing. Not one of the methods of coding is the perfect one, except we predict it's for the aim of our challenge. For those who assume you’re doing the whole lot proper, then so be it. In any other case simply attempt to use CSS Lint a number of occasions and see if it improves your outcomes. If it does, it is perhaps value to keep it up.

CSS Lint can also be an excellent approach for newbie builders to study extra about the best way they code and the best way they need to do it. There's nothing fallacious with that and it's by no means too late to study one thing new.

Do you assume CSS Lint is beneficial? Do you know about it or have you ever used it? Did it enhance the best way you code or the loading pace of your web site? Or was it a waste of time?

Now we're going to take a look at some CSS and HTML mixed, as the 2 are going hand in hand.

Do’s and Don’ts of Writing Higher CSS and HTML

CSS and HTML are key languages to start with, whenever you determine to speculate your time in net design and growth. They're highly effective languages and more often than not could appear easy to work with. Nonetheless, each single one in every of us, learners, or superior builders, have dedicated fundamental or main errors working with each these languages. With this in thoughts, I consider this can be very essential and at all times welcome to study some good suggestions and practices which I hope will enable you enhance your abilities and expertise.

A few of you might be considering that because you don’t see something misplaced when viewing your net web page, you might have your HTML and CSS paperwork constructed accurately, however you might be fallacious. The reality is that you shouldn't belief the whole lot you code. Utilizing the identical ID greater than as soon as on the identical web page received’t lead to fallacious alignments or retrieve any error (except you attempt to validate), however it's in actual fact unhealthy markup and a significant flaw in your code.


Not so way back, we had to make use of these actually lengthy Doctypes that have been nearly inconceivable to recollect. Now, because you simply want to make use of on the highest of your doc, we now have a a lot cleaner and higher answer. However, some individuals nonetheless forgets to specify it. That is obligatory for a validated and arranged HTML doc.

How it's best to do it

Always remember your DOCTYPE.

An ID is a novel identifier which permits us to focus on a particular ingredient on the web page and, since it's distinctive, it might probably solely be used as soon as in a web page. However, we now have courses which permit us to do precisely the other. Lessons are used when you might have the identical ingredient greater than as soon as on a web page.

Say no to inline styling

Inline styling is sadly a fairly widespread apply and on the identical time a foul one. It has nothing to do with invalid code or unhealthy markup, however with organized code and construction. Think about you might have 30 pages and you'll want to take away an inline type you might have utilized to the identical div on each single web page, it might take you without end and steal valuable time.

Ove use of divs and CSS Lessons

So that you began your personal challenge, you know the way to make use of divs, ids, and courses. Inline styling will not be your factor (luckily), and also you like to create types and apply them in every single place. That’s nice, however don’t write greater than it's important to. Having a div with an unordered listing inside and a category utilized to every li ingredient is pointless.

best to do it


Browser Decision

Based on the W3c’s newest statistics (January 2011), 13.8% of web customers have a 1024×768 display screen decision, and 85.1% use an even bigger display screen decision. So the query is “What decision I ought to design for?” I personally use a most width of 960 or 980 pixels for a vertical format and between 550 and 640 pixels in case of a horizontal format. Moreover, although 13.8% appears to be a reasonably low quantity, it nonetheless represents hundreds of thousands of web customers.

How it's best to do it

Take into account everybody’s wants, and particularly your audience.

Block vs Inline components

Differentiating block from inline components could be a a fragile matter for learners. A block ingredient is displayed on a brand new line taking by default 100% width of the containing ingredient, like divs (

Cross-Browser Compatibility

Once you determine to make one thing, it's best to place your self within the function of the end-user, and picture that, even right this moment, a few of them nonetheless use browsers like IE6. A web page in renders in another way in Firefox than in Chrome or Web Explorer. There are some helpful instruments you need to use to verify how your web page renders in several browsers. Charina wrote a really full article relating to this matter which I like to recommend studying – 10 Helpful Instruments For Cross-Browser Compatibility Test

How it's best to do it

Don't forget to concentrate to your format in several browsers, systematically.

Hold it quick – Generic courses, properties and CSS information

When you're coding it's best to at all times have one factor in thoughts, plan for the longer term. You might be already utilizing feedback and holding your code organized, so why cease right here? The very first thing I do after I’m coding CSS is to specify a bit of generic courses, then on my HTML I merely use them alongside with different components.

Textual content content material


How it's best to do it:

[code lang=”html”]

Publish title

Textual content content material


Use absolute place solely when it's important to

Once you’re beginning out, you may simply turn into hooked on the usage of absolute positioning. It's because it's a straightforward approach of putting components, nevertheless, this property shouldn't be used excessively. Since components with absolute place lose their regular stream, it's nearly inconceivable to align them with different sections on the web page. You merely can’t inform a standard ingredient to be on the left aspect of a component with absolute place.

How it's best to do it:

Use absolute place solely when you'll want to, and never as a result of it's simpler.

Kind fonts

So is there a font you actually like and you'd like to apply it to your web page, is it a regular font? What if not? These are are questions you'll want to ask earlier than you select your typography. Once you select a font you need to at all times have a backup plan, because of this in case the consumer doesn't have the chosen font, the second selection (or third, and many others) will seem. Examples of normal fonts are Arial, Georgia, Lucida Sans Code, Instances New Roman, Verdana, Tahoma, and a few extra. Now let’s say you wish to use a font that's non-standard, what would you do? The obvious reply is @font-face.

All the time validate

The title is fairly self-explanatory, it's best to at all times validate your CSS and HTML paperwork. Why? The reply is why not? You have got a option to know in case your code has errors and it offers you options to repair them, so actually, why not? Add CSS Validator and HTML Validator to your favourites.

How it's best to do it

Validate your CSS, and after that do the identical to your HTML.

Some might contemplate the following pointers and strategies widespread sense and easy to grasp, others not a lot, however the essential factor is that each coder make errors, and apply makes good.

Hope you loved the article and have some enjoyable experimenting, however maintain it organized!

The CSS Best Practices to Follow and the Bad Habits to Avoid.
The CSS Best Practices to Follow and the Bad Habits to Avoid.

The CSS Best Practices to Follow and the Bad Habits to Avoid.