CSS techniques I use all the time. I'm always learning new things with CSS. It's interesting because I've thought of myself as a CSS expert for a while now (I'll challenge anyone to a competition, seriously) but I still keep learning and improving. I've come across some techniques lately that are extremely valuable and worth sharing. Have a look: Initial Settings Text Readability Ever since I read the "100% Easy to Read Standard," I have stuck to some basic but highly important initial settings for text; "line-height:1.4" for readable lines, reasonable line-lengths that avoid lines much longer than 10 words, and colors that provide contrast without being too far apart.
For example, pure black on pure white is often too strong for bright CRT displays, so I try to go with an off-white (#fafafa is a good one) and a dark gray (#333333, another good one). EM calculations Sizing text is always an important part of making a usable design. The explanation for this comes from "CSS: Getting Into Good Coding Habits:" SEO Best Practices - Dynamic Pages in ASP.NET. One of the greatest time-savers in web development is the use of dynamic pages to serve up database driven content. The most common examples of which are content management systems and product information pages. More times than not these pages hinge on a querystring parameter such as /page.aspx? Id=12345 to determine which record needs to be retrieved from the database and output to the page. What is surprising is how many sites don't adequatly validate that crucial parameter.
Any parameter that can be tampered with by a user, such as a querystring, must be validated as a matter of basic security. With a dynamic page that depends on querystring parameters to generate its content, the following basic measures should be taken: Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load 'Ensure that the requested URI actually has any querystring keysIf Request.Querystring.HasKeys() Then Else Response.StatusCode = 404 Response.Redirect("/404.aspx",True) End If End Sub. 207 manually selected sites about Style Sheets. Home | Email Standards Project. 9 CSS Ethics Every Designer Should Have. Nov 10 2007 No need to get any more complicated structure than you need to. Writing a CSS Stylesheet That is Easy to Maintain is really easy, just by following these 9 rules.
How deeply you organize your CSS can greatly hinder any necessary tweaks that arise in the future. So, I proposed the question to my team to take a close look at some of the most interesting CSS coding structure and listed them below where you can probably use in every project you are developing. 1) Indent descendant and related rules: This allows you to easily recognize page structure within your CSS and how sections related to each other. [Erratic Wisdom] 2)Grouping and commenting your CSS rules Setup certain sections in your CSS files that always exists: page structure, links, header, footer, lists, etc. /* Header Styles Go Here **************/ ...CSS Code Goes Hereā¦/* End Header Styles *************/Header StructureNavigationFormsLinksHeadersContentListsCommon Classes 3) Keep style type on single line Instead of this:
PHP techniques I use all the time. Back in February, I was writing CSS every day and I decided to share some of the CSS techniques that I always use. Lately I've been writing more PHP than anything else and I've found myself using some very useful techniques all the time. Now I know that PHP isn't very "cool" these days; it's probably the most misunderstood web language because all the script kiddies use it to include files on their webpages and put up forms that get hacked hours later.
But I think PHP deserves a whole lot more credit than it gets; it's fast, it integrates very nicely with Apache, it got all the right features in version 5, and even if you don't like using it, there's always a chance you might have to write some anyway. So, maybe these tips can help you out: Use heredoc syntax for strings: If there's one thing I got tired of fast, it was building long strings like this: If I am going to make a string with more than one line, and even sometimes when I'm not, then I use heredoc.