SlideShare a Scribd company logo
1 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
Coding Standards
1.Comments on Code
Commented on Markup
<!-- header -->
Text information is separated from the tag by a “space ”. No additional symbols are
required.
This form is incorrect:
<!--  header ///// -->
<!-- *** header *** -->
You should comment:
1. main markup blocks (header, footer etc.)
2. main semantic blocks and elements (logo, navigation, breadcrumbs, article
etc.}
3. main functional blocks and elements (sub-navigation, popup, search contact
form etc.}
If it is impossible to find a semantic title, you can use a block heading or class as a title:
<!-- welcome block -->
or
<!-- block title -->
An example of the correct HTML comment:
<!-- main -->
<!-- header -->
<!-- navigation -->
<!-- content -->
Commented on CSS
/* article */
2 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
Text information is separated by a "space". No other additional symbols are required.
There is no need in closing comments. Just mark the beginning of the block styles.
The following form is incorrect:
/* ##### article ##### */
/* --== article ==-- */
Initial reset of elements (even if it is very small) should be commented as /* General
reset */.
Comments in CSS must correspond the comments in HTML.
If after "General reset" there follows the declaration of all main blocks, it is mentioned as
/* General settings */:
/* General settings */
#header{...}
#content{...}
#sidebar{...}
#footer{...}
An example of the correct CSS comment:
/* main */
/* header */
/* navigation */
/* content */
File Naming and Organization
The following example file structure should be used for static resources (framework-
specific conventions take precedence):
/css
/reset.css
/main.css
/ie.css
/images
/btn-submit.png
/btn-submit-SOURCE.psd
/js
3 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
Best Practices
 Use a global reset. A global reset helps create more consistent presentation
across browsers.
 Use sprites for all rollover/active states. CSS sprites prevent unwanted image
flicker on rollover. CSS sprites also reduce the total number of HTTP requests.
 Use as few browser-specific styles as possible. If needed, browser-specific
stylesheets or page classes (http://paulirish.com/2008/conditional-stylesheets-vs-
css-hacks-answer-neither/) should be used instead of putting CSS hacks in the
main stylesheet.
 Validate CSS.
Optimization Code and file
1. Use shorthand
If you’re not already writing in shorthand, you’re late to the party. But fortunately, this
party never ends. Using shorthand properties is the single easiest practice you can do to
cut down your code (and coding time). There’s no better time than the present to start
this efficient coding practice, or to review it.
Margin, border, padding, background, font, list-style, and even outline are all properties
that allow shorthand (and that’s not even an extensive list!).
CSS Shorthand means that instead of using different declarations for related
properties…
p { margin-top: 10px;
margin-right: 20px;
margin-bottom: 30px;
margin-left: 40px; }
… you may use shorthand properties to combine those values like so:
p { margin: 10px 20px 30px 40px; }
2. Axe the Hacks
we know that using conditional comments to serve hacks correctional declarations for IE6 and
IE7 is an accepted practice, even recommended by the Microsoft IE development team. Using
conditional comments to serve IE-specific CSS rules has the added benefit of serving a cleaner,
and therefore smaller, default CSS file to more standards-compliant browsers, while only those
browsers that need the hackery daiquri (i.e. IE) will download the additional page weight.
4 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
Here’s how to use conditional comments to serve styles only to Internet Explorer 6:
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="ie6.css">
<![endif]-->
3.Optimize the file
Optimize the jpg and png
PNG is useful because it's the only widely supported format that can store partially
transparent images. The format uses compression, but the files can still be large. Use
PNGauntlet and to optimize the jpeg file use the jpegmini tools to shrink images for your
apps and sites. It will use less bandwidth and load faster.
PNG optimize tool
4.Optimize the js code and css code
Use the single file for the js and css file as follows the all.css for all the css code and
jquery.js for all the customize jquery code.
5 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
5. Use whitespace wisely
Whitespace, including spaces, tabs, and extra line breaks, is important for readability for
CSS code. However, whitespace does add, however miniscule it may be, to page
weight. Every space, line-break, and tab you can eliminate is like having one less
character. Always favor for single line formatting option without tabs. Eg. As follows
Multi-line formatting, double-spaced, indented code
Example
.code-standard{
background:transparent;
width:205px;
border:none;
overflow:hidden;
cursor:pointer;
}
Single-line formatting, single-spaced, no indentation
Example
.code-
standard{background:transparent;width:205px;border:none;overflow:hidden;cursor:poi
nter;}
6.Tidying up your HTML tags with indentation
You may already be finding that it is a bit hard to look at the HTML in your editor and to
understand it. Part of this will be the layout (part will be that HTML is confusing for a
while).
To help you to see the structure of a Web page's HTML it is best to indent the code. This
means putting tabs into your HTML. Remember that these tabs will not be shown on the
6 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
Web page (extra spaces and tabs are ignored by browsers the same way as line
breaks).
The idea is to put a tab before each line of code which is inside another tag. This makes
more sense if you see it. This is what you have in your file so far but properly indented:
Example
Wrong and untidy markup indention
7 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
Clean markup with Proper indention.
What Beautiful HTML Code Looks Like
http://css-tricks.com/examples/CleanCode/Beautiful-HTML.png
6.Use HTML and CSS Validator
Why Code validation for?
 Validation as a debugging tool
 Validation as a future-proof quality check
 Validation eases maintenance
 Validation helps teach good practices
 Validation is a sign of professionalism
For Markup validation use
http://validator.w3.org/
8 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
For CSS validation use
http://jigsaw.w3.org/css-validator/
Use the same class for all the markup and css
standard
Class names
 .panel, .bar (block with navigation and additional elements)
 .navbar (block with navigation. There can be additional elements)
 .navigation (block / list for navigation only)
 .main-nav (.main-navigation - main navigation)
 .add-nav (.add-navigation – additional navigation)
 .breadcrumbs (block / list with breadcrumbs)
 .tags (used for tags / tag list displaying)
 .topiclist (list of topics)
 .item-list (.product-list, .article-list, .recent-articles) – list of items (products), list of
articles (sections), list of the most frequent articles (sections)
 .paging ( block / list with pagination)
 .news (.news-list) – a list of news
 .tools (a list with icons (home, contact, sitemap, print, etc.))
 classes for the items of such list are:
.home, .contact, .sitemap, .print, etc.
Forms
 .login (.login-form)
 .search (.search-form)
 .subscribe (news subscription etc.)
 .newsletter (newsletters subscription)
 .details (a form with contact details)
 .profile (profile)
 .account (account (register entry))
 .information (a additional information form)
 .feedback (feedback communication)
 .poll, survey (poll)
 .vote (voting)
 .some-form (chose an appropriate word instead of “some”)
Step-by-step actions (used for forms, shopping forms etc)
 .steps (steps)
9 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
 .step - (step)
Blog
 .post – single post
 .entry-title – post title
 .entry-content - content of the post
 .meta - meta information about the post
 .updated - an update time
 .published - the time of publication
 .date (just em tag) - the date of publication
 .timestamp – label or tag of the post
 .discussion – comments block
 .comments - comments
 .list-comments - list of comments
 .add-comments – add a comment
RSS-icons
 .feed
 .rss
Active states
 .active
 .selected
Other units
 .box (block with borders)
 .block (can be borderless)
 .container (can be borderless)
 .section (for additional section)
 .item (to format a block with additional content, or any singular item, object
etc).
 .products (block with list of products)
 .items (block with a list of any additional elements)
 .article (block for an article or for the item / product description)
 .books (books, book description)
 .calendar (calendar)
 .visual ( block for images (for example: images attache to the article, post))
 .promobox (block for advertisements only)
 .photo (for photos)
 .featured-item (featured items)
 .alignleft, .alignright, .aligncenter (to align an image in the content part)
10 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
Header
 .logo
 .slogan
Footer
 .copyright
 .by
 .nav - if the list duplicates navigation links
 .listing (list) – for lists (do not use the class for the list if it is not necessary)
 .doc - if these are links to documentation («privacy», etc.)
Testimonials:
 .testimonials
More
 .all, .more ( link to display all content)
 .another (another)
 .details (link to additional information page)
General page layout
1. main block of the page - #wrapper.
2. main navigation of the page - #nav.
3. ID to be used for the following elements:
o #header (“billhead” of the document);
also possible:
o #main (page content );
o #twocolumns ( column: # content + sidebar);
o #content (content of the column);
o #sidebar (a unique column to the left or the right of the # content);
o #footer (foot of the page);
o elements for JavaScript;
o form elements that are associated with the corresponding label in
for / id.
Examples of marking for pages.
11 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
To mark up a unique side column use #sidebar.
To mark up an additional side column use .aside (. aside1,. aside2 if there are
two of them).
 Page with the main column and unique sidebar: ::
Doubleclick to copy
<div id="wrapper">
<div id="header"></div>
<div id="main">
<div id="content"></div>
<div id="sidebar"></div>
</div>
<div id="footer"></div>
</div>
 Page with the main column, unique sidebar and one additional column: ::
Doubleclick to copy
<div id="wrapper">
<div id="header"></div>
<div id="main">
<div id="twocolumns">
<div id="content"></div>
<div class="aside"></div>
</div>
<div id="sidebar"></div>
</div>
<div id="footer"></div>
</div>
 The page with the main column and two additional columns: ::
Doubleclick to copy
<div id="wrapper">
<div id="header"></div>
<div id="main">
<div id="twocolumns">
<div id="content"></div>
<div class="aside1"></div>
</div>
<div class="aside2"></div>
</div>
<div id="footer"></div>
12 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan,
designersaajan@gmail.com, Kathmandu ,Nepal.
</div>
Naming and accessibility
 logo.gif – main logo of the page
 logo.gif...logo10.gif – logos list
The logo image can be named after the owner's company
Examples: puma.gif, adidas.gif, microsoft.gif, contex.gif, durex.gif
 sponsor-logo1.gif (partner-logo1.gif – depending on the logo list title) – sponsors'
logos can also be named based on the companies' names: adidas.gif,
w3ukraine.gif etc, but please follow a certain logical order f.ex. there must be no
adidas.gif and logo10.gif in one list.
 btn-go.gif, btn-submit.gif, btn-name.gif – for form elements or for big block links.
 text-sometext.gif – for text replacement (titles).
 bg-body.gif, bg-footer.gif – for background images.
 img1.gif, img2.gif, item1.gif, item2.gif – for product lists, or non-systematized
images.
 ico-email.gif, ico-star.gif, flag-ua.gif, flag-uk.gif – for icons.
 separator.gif, divider.gif – if the image is being used as a separator
 bullet.gif(bullet-green.gif, bullet1.gif, bullet5.gif, bullet-small.gif, bullet-medium.gif)
– if the image is being used for list styling.
Variants of naming: arrow, arrow-red, arrow-small, arrow-left etc.
Image title must always be meaningful.
Do not write anything into “alt” attribute to preserve images accessibility.
We only write data into “alt” attribute when there is a demand of Web Accessibility,
SEO or Section508. “Alt” attribute content has to reflect the content or meaning of the
image. If it is impossible/difficult to write the content correctly, then put «image
description» in the “alt”
If Web Accessibility, SEO or Section508 are NOT required then you can set 'image
description' for all images.
If the image is meaningless (simply for design purposes) you don't need to set “alt”
attribute.

More Related Content

What's hot

Css
CssCss
CSS
CSS CSS
CSS
Sunil OS
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
Jacob Nelson
 
HTML5 Media Elements
HTML5 Media ElementsHTML5 Media Elements
CSS media types
CSS media typesCSS media types
CSS media types
Russ Weakley
 
Specificity and CSS Selectors
Specificity and CSS SelectorsSpecificity and CSS Selectors
Specificity and CSS Selectors
palomateach
 
Sightly - Part 2
Sightly - Part 2Sightly - Part 2
Sightly - Part 2
Prabhdeep Singh
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
fantasticdigitaltools
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
Seble Nigussie
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
Anuradha
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
Swati Sharma
 
Basic-CSS-tutorial
Basic-CSS-tutorialBasic-CSS-tutorial
Basic-CSS-tutorial
tutorialsruby
 
SQL: Creating and Altering Tables
SQL: Creating and Altering TablesSQL: Creating and Altering Tables
SQL: Creating and Altering Tables
RJ Podeschi
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
What is context? How to use context in Odoo by weblearns
What is context? How to use context in Odoo by weblearnsWhat is context? How to use context in Odoo by weblearns
What is context? How to use context in Odoo by weblearns
Web Learns
 
Javascript
JavascriptJavascript
Javascript
Nagarajan
 
Html
HtmlHtml
Css
CssCss
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert
 
Basic HTML
Basic HTMLBasic HTML
Basic HTML
Sayan De
 

What's hot (20)

Css
CssCss
Css
 
CSS
CSS CSS
CSS
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
 
HTML5 Media Elements
HTML5 Media ElementsHTML5 Media Elements
HTML5 Media Elements
 
CSS media types
CSS media typesCSS media types
CSS media types
 
Specificity and CSS Selectors
Specificity and CSS SelectorsSpecificity and CSS Selectors
Specificity and CSS Selectors
 
Sightly - Part 2
Sightly - Part 2Sightly - Part 2
Sightly - Part 2
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
 
Basic-CSS-tutorial
Basic-CSS-tutorialBasic-CSS-tutorial
Basic-CSS-tutorial
 
SQL: Creating and Altering Tables
SQL: Creating and Altering TablesSQL: Creating and Altering Tables
SQL: Creating and Altering Tables
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
What is context? How to use context in Odoo by weblearns
What is context? How to use context in Odoo by weblearnsWhat is context? How to use context in Odoo by weblearns
What is context? How to use context in Odoo by weblearns
 
Javascript
JavascriptJavascript
Javascript
 
Html
HtmlHtml
Html
 
Css
CssCss
Css
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Basic HTML
Basic HTMLBasic HTML
Basic HTML
 

Similar to HTML and CSS Coding Standards

HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
tutorialsruby
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
tutorialsruby
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
Sanjoy Kr. Paul
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
William Myers
 
Web technologies part-2
Web technologies part-2Web technologies part-2
Web technologies part-2
Michael Anthony
 
Css training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentialsCss training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentials
QA TrainingHub
 
Introduction to BOOTSTRAP
Introduction to BOOTSTRAPIntroduction to BOOTSTRAP
Introduction to BOOTSTRAP
Jeanie Arnoco
 
Twitter bootstrap training_session_ppt
Twitter bootstrap training_session_pptTwitter bootstrap training_session_ppt
Twitter bootstrap training_session_ppt
Radheshyam Kori
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
Zohar Arad
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
butest
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
butest
 
HTML Foundations, part 1
HTML Foundations, part 1HTML Foundations, part 1
HTML Foundations, part 1
Shawn Calvert
 
The CSS Handbook
The CSS HandbookThe CSS Handbook
The CSS Handbook
jackchenvlo
 
Css week10 2019 2020 for g10 by eng.osama ghandour
Css week10 2019 2020 for g10 by eng.osama ghandourCss week10 2019 2020 for g10 by eng.osama ghandour
Css week10 2019 2020 for g10 by eng.osama ghandour
Osama Ghandour Geris
 
CSS framework By Palash
CSS framework By PalashCSS framework By Palash
CSS framework By Palash
PalashBajpai
 
Html & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshopHtml & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshop
Vero Rebagliatte
 
Html and html5 cheat sheets
Html and html5 cheat sheetsHtml and html5 cheat sheets
Html and html5 cheat sheets
Zafer Galip Ozberk
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
nikhilsh66131
 
Teched Inetrgation ppt and lering in simple
Teched Inetrgation ppt  and lering in simpleTeched Inetrgation ppt  and lering in simple
Teched Inetrgation ppt and lering in simple
JagadishBabuParri
 
Css week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandourCss week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandour
Osama Ghandour Geris
 

Similar to HTML and CSS Coding Standards (20)

HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Web technologies part-2
Web technologies part-2Web technologies part-2
Web technologies part-2
 
Css training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentialsCss training tutorial css3 &amp; css4 essentials
Css training tutorial css3 &amp; css4 essentials
 
Introduction to BOOTSTRAP
Introduction to BOOTSTRAPIntroduction to BOOTSTRAP
Introduction to BOOTSTRAP
 
Twitter bootstrap training_session_ppt
Twitter bootstrap training_session_pptTwitter bootstrap training_session_ppt
Twitter bootstrap training_session_ppt
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
 
HTML Foundations, part 1
HTML Foundations, part 1HTML Foundations, part 1
HTML Foundations, part 1
 
The CSS Handbook
The CSS HandbookThe CSS Handbook
The CSS Handbook
 
Css week10 2019 2020 for g10 by eng.osama ghandour
Css week10 2019 2020 for g10 by eng.osama ghandourCss week10 2019 2020 for g10 by eng.osama ghandour
Css week10 2019 2020 for g10 by eng.osama ghandour
 
CSS framework By Palash
CSS framework By PalashCSS framework By Palash
CSS framework By Palash
 
Html & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshopHtml & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshop
 
Html and html5 cheat sheets
Html and html5 cheat sheetsHtml and html5 cheat sheets
Html and html5 cheat sheets
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Teched Inetrgation ppt and lering in simple
Teched Inetrgation ppt  and lering in simpleTeched Inetrgation ppt  and lering in simple
Teched Inetrgation ppt and lering in simple
 
Css week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandourCss week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandour
 

Recently uploaded

Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
widenerjobeyrl638
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
campbellclarkson
 
What is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdfWhat is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdf
kalichargn70th171
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
confluent
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
Optimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptxOptimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptx
WebConnect Pvt Ltd
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
kalichargn70th171
 
The Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdfThe Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdf
mohitd6
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert
vaishalijagtap12
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
kalichargn70th171
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
Luigi Fugaro
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
Zycus
 

Recently uploaded (20)

Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
 
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
🏎️Tech Transformation: DevOps Insights from the Experts 👩‍💻
 
What is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdfWhat is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdf
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
bgiolcb
bgiolcbbgiolcb
bgiolcb
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
Optimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptxOptimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptx
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
 
The Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdfThe Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdf
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert42 Ways to Generate Real Estate Leads - Sellxpert
42 Ways to Generate Real Estate Leads - Sellxpert
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
 
How GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdfHow GenAI Can Improve Supplier Performance Management.pdf
How GenAI Can Improve Supplier Performance Management.pdf
 

HTML and CSS Coding Standards

  • 1. 1 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. Coding Standards 1.Comments on Code Commented on Markup <!-- header --> Text information is separated from the tag by a “space ”. No additional symbols are required. This form is incorrect: <!-- header ///// --> <!-- *** header *** --> You should comment: 1. main markup blocks (header, footer etc.) 2. main semantic blocks and elements (logo, navigation, breadcrumbs, article etc.} 3. main functional blocks and elements (sub-navigation, popup, search contact form etc.} If it is impossible to find a semantic title, you can use a block heading or class as a title: <!-- welcome block --> or <!-- block title --> An example of the correct HTML comment: <!-- main --> <!-- header --> <!-- navigation --> <!-- content --> Commented on CSS /* article */
  • 2. 2 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. Text information is separated by a "space". No other additional symbols are required. There is no need in closing comments. Just mark the beginning of the block styles. The following form is incorrect: /* ##### article ##### */ /* --== article ==-- */ Initial reset of elements (even if it is very small) should be commented as /* General reset */. Comments in CSS must correspond the comments in HTML. If after "General reset" there follows the declaration of all main blocks, it is mentioned as /* General settings */: /* General settings */ #header{...} #content{...} #sidebar{...} #footer{...} An example of the correct CSS comment: /* main */ /* header */ /* navigation */ /* content */ File Naming and Organization The following example file structure should be used for static resources (framework- specific conventions take precedence): /css /reset.css /main.css /ie.css /images /btn-submit.png /btn-submit-SOURCE.psd /js
  • 3. 3 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. Best Practices  Use a global reset. A global reset helps create more consistent presentation across browsers.  Use sprites for all rollover/active states. CSS sprites prevent unwanted image flicker on rollover. CSS sprites also reduce the total number of HTTP requests.  Use as few browser-specific styles as possible. If needed, browser-specific stylesheets or page classes (http://paulirish.com/2008/conditional-stylesheets-vs- css-hacks-answer-neither/) should be used instead of putting CSS hacks in the main stylesheet.  Validate CSS. Optimization Code and file 1. Use shorthand If you’re not already writing in shorthand, you’re late to the party. But fortunately, this party never ends. Using shorthand properties is the single easiest practice you can do to cut down your code (and coding time). There’s no better time than the present to start this efficient coding practice, or to review it. Margin, border, padding, background, font, list-style, and even outline are all properties that allow shorthand (and that’s not even an extensive list!). CSS Shorthand means that instead of using different declarations for related properties… p { margin-top: 10px; margin-right: 20px; margin-bottom: 30px; margin-left: 40px; } … you may use shorthand properties to combine those values like so: p { margin: 10px 20px 30px 40px; } 2. Axe the Hacks we know that using conditional comments to serve hacks correctional declarations for IE6 and IE7 is an accepted practice, even recommended by the Microsoft IE development team. Using conditional comments to serve IE-specific CSS rules has the added benefit of serving a cleaner, and therefore smaller, default CSS file to more standards-compliant browsers, while only those browsers that need the hackery daiquri (i.e. IE) will download the additional page weight.
  • 4. 4 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. Here’s how to use conditional comments to serve styles only to Internet Explorer 6: <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="ie6.css"> <![endif]--> 3.Optimize the file Optimize the jpg and png PNG is useful because it's the only widely supported format that can store partially transparent images. The format uses compression, but the files can still be large. Use PNGauntlet and to optimize the jpeg file use the jpegmini tools to shrink images for your apps and sites. It will use less bandwidth and load faster. PNG optimize tool 4.Optimize the js code and css code Use the single file for the js and css file as follows the all.css for all the css code and jquery.js for all the customize jquery code.
  • 5. 5 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. 5. Use whitespace wisely Whitespace, including spaces, tabs, and extra line breaks, is important for readability for CSS code. However, whitespace does add, however miniscule it may be, to page weight. Every space, line-break, and tab you can eliminate is like having one less character. Always favor for single line formatting option without tabs. Eg. As follows Multi-line formatting, double-spaced, indented code Example .code-standard{ background:transparent; width:205px; border:none; overflow:hidden; cursor:pointer; } Single-line formatting, single-spaced, no indentation Example .code- standard{background:transparent;width:205px;border:none;overflow:hidden;cursor:poi nter;} 6.Tidying up your HTML tags with indentation You may already be finding that it is a bit hard to look at the HTML in your editor and to understand it. Part of this will be the layout (part will be that HTML is confusing for a while). To help you to see the structure of a Web page's HTML it is best to indent the code. This means putting tabs into your HTML. Remember that these tabs will not be shown on the
  • 6. 6 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. Web page (extra spaces and tabs are ignored by browsers the same way as line breaks). The idea is to put a tab before each line of code which is inside another tag. This makes more sense if you see it. This is what you have in your file so far but properly indented: Example Wrong and untidy markup indention
  • 7. 7 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. Clean markup with Proper indention. What Beautiful HTML Code Looks Like http://css-tricks.com/examples/CleanCode/Beautiful-HTML.png 6.Use HTML and CSS Validator Why Code validation for?  Validation as a debugging tool  Validation as a future-proof quality check  Validation eases maintenance  Validation helps teach good practices  Validation is a sign of professionalism For Markup validation use http://validator.w3.org/
  • 8. 8 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. For CSS validation use http://jigsaw.w3.org/css-validator/ Use the same class for all the markup and css standard Class names  .panel, .bar (block with navigation and additional elements)  .navbar (block with navigation. There can be additional elements)  .navigation (block / list for navigation only)  .main-nav (.main-navigation - main navigation)  .add-nav (.add-navigation – additional navigation)  .breadcrumbs (block / list with breadcrumbs)  .tags (used for tags / tag list displaying)  .topiclist (list of topics)  .item-list (.product-list, .article-list, .recent-articles) – list of items (products), list of articles (sections), list of the most frequent articles (sections)  .paging ( block / list with pagination)  .news (.news-list) – a list of news  .tools (a list with icons (home, contact, sitemap, print, etc.))  classes for the items of such list are: .home, .contact, .sitemap, .print, etc. Forms  .login (.login-form)  .search (.search-form)  .subscribe (news subscription etc.)  .newsletter (newsletters subscription)  .details (a form with contact details)  .profile (profile)  .account (account (register entry))  .information (a additional information form)  .feedback (feedback communication)  .poll, survey (poll)  .vote (voting)  .some-form (chose an appropriate word instead of “some”) Step-by-step actions (used for forms, shopping forms etc)  .steps (steps)
  • 9. 9 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal.  .step - (step) Blog  .post – single post  .entry-title – post title  .entry-content - content of the post  .meta - meta information about the post  .updated - an update time  .published - the time of publication  .date (just em tag) - the date of publication  .timestamp – label or tag of the post  .discussion – comments block  .comments - comments  .list-comments - list of comments  .add-comments – add a comment RSS-icons  .feed  .rss Active states  .active  .selected Other units  .box (block with borders)  .block (can be borderless)  .container (can be borderless)  .section (for additional section)  .item (to format a block with additional content, or any singular item, object etc).  .products (block with list of products)  .items (block with a list of any additional elements)  .article (block for an article or for the item / product description)  .books (books, book description)  .calendar (calendar)  .visual ( block for images (for example: images attache to the article, post))  .promobox (block for advertisements only)  .photo (for photos)  .featured-item (featured items)  .alignleft, .alignright, .aligncenter (to align an image in the content part)
  • 10. 10 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. Header  .logo  .slogan Footer  .copyright  .by  .nav - if the list duplicates navigation links  .listing (list) – for lists (do not use the class for the list if it is not necessary)  .doc - if these are links to documentation («privacy», etc.) Testimonials:  .testimonials More  .all, .more ( link to display all content)  .another (another)  .details (link to additional information page) General page layout 1. main block of the page - #wrapper. 2. main navigation of the page - #nav. 3. ID to be used for the following elements: o #header (“billhead” of the document); also possible: o #main (page content ); o #twocolumns ( column: # content + sidebar); o #content (content of the column); o #sidebar (a unique column to the left or the right of the # content); o #footer (foot of the page); o elements for JavaScript; o form elements that are associated with the corresponding label in for / id. Examples of marking for pages.
  • 11. 11 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. To mark up a unique side column use #sidebar. To mark up an additional side column use .aside (. aside1,. aside2 if there are two of them).  Page with the main column and unique sidebar: :: Doubleclick to copy <div id="wrapper"> <div id="header"></div> <div id="main"> <div id="content"></div> <div id="sidebar"></div> </div> <div id="footer"></div> </div>  Page with the main column, unique sidebar and one additional column: :: Doubleclick to copy <div id="wrapper"> <div id="header"></div> <div id="main"> <div id="twocolumns"> <div id="content"></div> <div class="aside"></div> </div> <div id="sidebar"></div> </div> <div id="footer"></div> </div>  The page with the main column and two additional columns: :: Doubleclick to copy <div id="wrapper"> <div id="header"></div> <div id="main"> <div id="twocolumns"> <div id="content"></div> <div class="aside1"></div> </div> <div class="aside2"></div> </div> <div id="footer"></div>
  • 12. 12 Markup and CSS Code Standardization.| Prepared by: Saajan Maharjan, designersaajan@gmail.com, Kathmandu ,Nepal. </div> Naming and accessibility  logo.gif – main logo of the page  logo.gif...logo10.gif – logos list The logo image can be named after the owner's company Examples: puma.gif, adidas.gif, microsoft.gif, contex.gif, durex.gif  sponsor-logo1.gif (partner-logo1.gif – depending on the logo list title) – sponsors' logos can also be named based on the companies' names: adidas.gif, w3ukraine.gif etc, but please follow a certain logical order f.ex. there must be no adidas.gif and logo10.gif in one list.  btn-go.gif, btn-submit.gif, btn-name.gif – for form elements or for big block links.  text-sometext.gif – for text replacement (titles).  bg-body.gif, bg-footer.gif – for background images.  img1.gif, img2.gif, item1.gif, item2.gif – for product lists, or non-systematized images.  ico-email.gif, ico-star.gif, flag-ua.gif, flag-uk.gif – for icons.  separator.gif, divider.gif – if the image is being used as a separator  bullet.gif(bullet-green.gif, bullet1.gif, bullet5.gif, bullet-small.gif, bullet-medium.gif) – if the image is being used for list styling. Variants of naming: arrow, arrow-red, arrow-small, arrow-left etc. Image title must always be meaningful. Do not write anything into “alt” attribute to preserve images accessibility. We only write data into “alt” attribute when there is a demand of Web Accessibility, SEO or Section508. “Alt” attribute content has to reflect the content or meaning of the image. If it is impossible/difficult to write the content correctly, then put «image description» in the “alt” If Web Accessibility, SEO or Section508 are NOT required then you can set 'image description' for all images. If the image is meaningless (simply for design purposes) you don't need to set “alt” attribute.