Beginner’s Guide To: Building HTML5/CSS3 Webpages |
Beginner’s Guide To: Building HTML5/CSS3 Webpages Posted: 04 Oct 2011 05:33 AM PDT HTML5 and CSS3 have swept the web by storm in only 2 years. Before them there have been many altered semantics in the way web designers are expected to create web pages, and with their arrival come a slew of awesome supports such as alternative media, XML-style tags, and progressive input attributes for web designers to achieve dreamy features like animation.
Though most developers seem to showcase potential yet complicated demos, HTML5/CSS3 are not really rocket science, and I’ll be walking you through the relaxing process to build a standard HTML5/CSS3 web page with comprehensive yet in-depth explanation and tada! Bonuses like learning resources and free HTML5 templates are available for you, so take this chance to kick-start your HTML5 journey!
Changes between HTML4 and HTML5You may be wondering why it’s even important to switch into HTML5. There are a myriad of reasons, but mostly because you’ll be working with the global Internet standards like every other designer. In this way you’ll find more support online and your websites will render properly in modern browsers which are constantly improved.
Comparison between HTML4 and HTML5 is difficult to spot at surface level. From viewing the new HTML5 draft you can see featured elements and corrected error handling procedures. Browser developers have specifically enjoyed the new specifications for rendering default web pages. What’s more from HTML5 is the conversion of our modern web browser. With these new specifications the web as a whole is now viewed as an application platform for HTML (especially HTML5), CSS, and JavaScript to be built upon. Also, this system elegantly creates harmony between web designers and developers by setting common standards which all browsers should follow. Additionally many elements have been created to represent new-age digital media. These include Bare HTML5 SkeletonI find the easiest way to understand any topic is to dive right into it. So I’ll be constructing a very basic HTML5 skeleton template for a web page. I included a few of the newer elements, which I hope to categorize a bit later. <!doctype html> <head> <meta charset="utf-8"> <title>Our First HTML5 Page</title> <meta name="description" content="Welcome to my basic template."> <link rel="stylesheet" href="css/style.css?v=1"> </head> <body> <div id="wrapper"> <header> <h1>Welcome, one and all!</h1> <nav> <ul> <li><a rel="external" href="#">Home</a></li> <li><a rel="external" href="#">About us</a></li> <li><a rel="external" href="#">Contacts</a></li> </ul> </nav> </header> <div id="core" class="clearfix"> <section id="left"> <p>some content here.</p> </section> <section id="right"> <p>but some here as well!</p> </section> </div> <footer> <p>Some copyright and legal notices here. Maybe use the © symbol a bit.</p> </footer> </div> </body> </html> Right away this isn’t very different from a standard HTML4 web page. What you may notice is that we do not need to include any more self-closing tags. This is truly wonderful news as it will save lots of time off your development projects. For those who don’t know, in XHTML drafts there were many elements labelled self-closing. These would end with a forward slash before the ‘greater than’ operator to signify you wouldn’t need to include another closing tag elsewhere. As an example, to create a meta keywords tag you would use This rule still applies in HTML5. But now you don’t even need the extra forward slash! Defining our Page AreasThe majority of our new code shouldn’t be too shocking. Our doctype is hilariously simpler than ever, no need for excessive body attributes, and information in our heading is clearly labelled. Moving on I’d like to focus your attention on the content inside our First you’ll see the entire page is encapsulated within a div tag. I’ve labelled this with an ID of wrapper, meaning it wraps around our entire website content. This is useful to set a maximum width or position content around on the screen. Next I’ve fractured the page into 3 core elements – one Now for the Similarly the quiet footer tag works well to differentiate this content among the page. Inside I have placed a solemn paragraph which may contain some copyright and ownership information. But chances are good you’ll want to include a bit more content, such as secondary links to your pages. Creative CSS3 WizardryTo finish off this basic stencil layout we can use a few CSS styles. In the basic HTML5 template I added an external CSS stylesheet so we can keep our code areas separated. This will clear up a lot of confusion in the long run when your pages and styles begin to run on for different pages.
So I haven’t spent a great deal of time with CSS, but enough to showcase a couple of neat effects. First off I’ve used some of the border-radius settings to build very cool navigation link hover effects. You can target this same effect in the template code, just add the following lines into the CSS document. nav { display: block; margin-bottom: 10px; } nav ul { list-style: none; font-size: 14px; } nav ul li { display: inline; } nav ul li a { display: block; float: left; padding: 3px 6px; color: #575c7d; text-decoration: none; font-weight: bold; } nav ul li a:hover { background: #deff90; color: #485e0f; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; padding: 3px 6px; margin: 0; text-decoration: none; } Another neat effect is the clearfix styles. This isn’t an entirely new concept with CSS3, but it is important for building standards-compliant web pages. Often when you’re looking to float content next to each other you’ll experience buggy positioning glitches. This is caused by offset margins and errors in setting absolute widths for your floated content. This concept can seem a bit confusing, and I’ve added a small bit of code below to help. Basically we’re targeting two /* page core */ div#core { display: block; clear: both; margin-bottom: 20px; } section#left { width: 550px; float: left; margin: 0 15px; } section#right { float: left; width: 300px; } /* clearfix */ .clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; } .clearfix { display: inline-block; } html[xmlns] .clearfix { display: block; } * html .clearfix { height: 1%; } These bits of code are simple for getting started. They also pertain to our HTML5 template code constructed earlier, so this is simple practice. But when it comes to real web junkies you’ll be looking into more CSS3 functionality. Lesser Known CSS3 SyntaxTo construct full HTML5/CSS3 web pages you’ll begin to use some much more complex stylesheets. Many designers know of shorthand code (such as the But there are a few new properties in CSS3 which many designers aren’t thinking about. Many of these aren’t just for aesthetics, but also include animation effects. Below is a short list explaining a few of the properties you may consider playing with. Try googling for syntax examples if you feel lost.
These properties all have their upsides and downfalls. I wouldn’t recommend trying to cram them all into your web pages. But practice will give you a clear mindset to enter into developing further websites with ease. One more core piece of added syntax worth mentioning is attribute selectors. With CSS3 you can now define styles based on HTML attributes (such as type, href, title) and even provide specific values. So for example we could target links with a defined title attribute and give them a set of background icon. ul li[title^="ico"] { background: url('my-icon.gif'); } If you notice I’ve included a carrot symbol before the equals sign. This is an operator which defines all list items holding the prefix, ico. Alternatively you can replace the carrot(^) with a dollar sign($) to target the suffix area of your title. In this way CSS3 knows to add background images where you could set the titles as ‘first ico’ or ‘book ico’. Read up a bit more about attribute selectors if you’re interested. Putting it All TogetherAt the core of HTML5 and CSS3 web pages is simplicity. Web developers are trying to build highly creative websites in less time and with less stress. The new features in HTML5 allow this with plenty of wiggle room. And using some of the new CSS3 selectors and properties will give you advantages in the long run.
But as well you should be considering the end user. The process of building a web page ultimately ends after launching the website public. Your goal is to please audience with easy-to-access information, and not just human readers, but search engine crawlers and indexing bots. Semantics have greatly evolved to include new HTML5 layout elements, splitting up page layouts consistently. It’s never been easier to construct a small navigation and footer section in line with all modern web browsers. Once you have become comfortable building HTML5 web pages you’ll likely start looking into page animations. Even minor effects with JavaScript and AJAX can majorly improve user experience and site performance. Although this isn’t part of the article scope, I recommend toying around with jQuery if you have any time. The open source library is astounding and allows for rapid prototyping on top of HTML5 page elements. Additional ResourcesBloggers all around the world have been discussing the new trends in HTML5 and CSS3 and sharing resources to the public. The time is changing and the web community is changing with them. You should consider a few niche areas to study into and build a small interest. Below are some additional lists, articles and tutorials you may enjoy. I’ve taken the liberty of splitting the lists into HTML5 and CSS3 resources. Based on what you’re looking into there should be a few topics here for everybody. Also enjoy the brief gallery of free HTML themes available for download online! HTML5
CSS3
Bonus: HTML5 Templates & ThemesDesign CompanyReady to step into the wonderful world of HTML5? Here’s a completely free HTML5 template, with jQuery scripts and custom fonts armed for you to test freely! A HTML5/CSS3 ThemeThis HTML5/CSS3 powered theme has common blog’s layout design for you to either build your own HTML5 blog with extensive features, or simply dig into the code and learn something about it. SpectacularThe spectacular WordPress theme comes in 2 flavors: HTML4.01 and HTML5, making it a very good resource to learn the coding difference between the HTML brothers. YokoYoko is a modern WordPress theme talking about flexibility with its responsive layout based on CSS3 media queries, which is the ability to adjust to different screen sizes, get to know about it! GreyIf you prefer the classic WordPress blog’s style, Grey is probably for you with its built-in CSS3 features like border-radius, multiple backgrounds, text-shadow, etc. |
You are subscribed to email updates from hongkiat.com To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
0 comments:
Post a Comment