The following are some of the important points that i had gathered during my learning of CSS and HTML markup. It also contains the important factors to consider when converting a given PSD or image into a good HTML markup and CSS.
Slicing techniques
- Do not slice the logo
- Figure out the gradient for repeating along the x -axis
- Dont start with the slice tool from the toolbar
- Always design with a wrapper div - for a row or a column - to be enclosed as a container tag
- Decide upon only one type of slicing for a given layout - for the wrapper divs and then perform the slicing
- First horizontal - because the flow goes from right to left
- After selecting the slice, divide the slice and give the number of dividers you would need
- Save for Web and Devices - Gif and PNG for transparent ones
- Quality generally set up as 75-85%
Remember
- height, width, padding, margin, float - main important properties
- use the following (or use a reset)
body{padding:0;
margin:0;
}
- Give Wrapper
margin:auto;
to make the whole container centered - Give fixed width and height to get the margin auto to work properly
- Div dimensions: width + margin + padding + border
- Whenever u are adding a padding or margin, adjust the width or height appropriately
- Use
margin:auto;
to center the div within the container \#nav ul{ margin:0; padding:0;}
- remember for every UL block or use a reset- Always use
ul{list-style-type: none;}
- Give
li{display:block}
and provide width & height to get a BUTTON look and feel - For vertical nav bar, when absolute position is used, use negative margin-left and margin-top of size half of the width and height of the div.
- Always the target browsers and supported resolutions needs to be decided
Media Queries
- Change float to normal using the height/width/float properties for changing screen size
- Always use
margin,padding:0
- for reset - Types of layouts - pure fluid / pure display oriented / hybrid .. Fluid Layout … system of relative layout instead of absolute pixels … height/width - only in percentages
.. Adaptive Layout … using the (media?) tags
.. Responsive Layout … Mix of Fluid and adaptive layouts. PERCENTAGE + Media Tags
- New way of setting the media value [source,html]
<meta name="viewport" content="initial-scale=1,width=device-width">
- Media query representation
@media screen and (max-width: 980px){
.... }
- Always create the smallest resolution first
- Try to use different images with different srcs to cater to different sizes
Types of Selectors
- Tag
- Class
- Pseudo-element
[first-line, first-character]
This is the LEAST important selector - Contextual/Conditional - selective styling -
p strong{}
- Group/Compound selector - more than 1 tag
- Pseudo-class
[link,active,hover,visited]
- MORE important than the other pseudo-element - ID Selector
- when to use id vs class? .. Use Class references with Less weightage .. Use the TAG selectors first
Selectors Precedence
- The precedence for any style flows as :
inline > Embedded > External
- The precedence for any selector: id > class > tag
- For more details, refer to
- http://www.w3.org/TR/CSS21/cascade.html#specificity[Specificity]
- http://www.w3.org/TR/CSS2/selector.html[Selector]
- http://css-tricks.com/specifics-on-css-specificity/[CSS Tricks]
Hierarchy of precedence
- The ID selector
- The attribute selector
- The class selector
- The child selector
- The adjacent sibling selector -
.blog-img + p
- The descendant selector
- The tag selector
Shorthand syntax
###= background
: url(example.gif);
background: #eaeaea ;
background-color: repeat-x;
background-repeat: top left; background-position
can be written as:
: #eaeaea url(example.gif) repeat-x top left; background
###= border
: red;
border-color: 1px;
border-width: solid; border-style
can be written as:
: 1px solid red; border
###= list
: outside;
list-style-position: none;
list-style-image: disc; list-style-type
can be written as:
: disc outside;` list-style
the general format for a list style is:
: [list-style-type] [list-style-position] [list-style-image]; list-style
font
: Arial, Helvetica;
font-family: bold;
font-weight: italic;
font-style: 1em;
font-size: 1.5em; line-height
can be written as:
: bold italic 1em/1.5em Arial, Helvetica; font
###= margin The margin properties allows a shorthand for margin-top, margin-right, margin-bottom and margin-left.
/* top=10px, right=5px, bottom=15px, left=20px */
: 10px 5px 15px 20px;
margin
/* top=10px, right=5px, bottom=10px, left=5px*/
: 10px 5px;
margin
/* top=10px, right=5px, bottom=15px, left=5px*/
: 10px 5px 15px; margin
Form features in HTML5
- Placeholder text
- Slider control
- Calendar/Date picker
- autocomplete
- Input type Search
CSS features in HTML5
- Shadow - box shadow, text shadow
- Gradient
- Blur
- column text
- transform / transitions
- Rounded corners (using border radius)
- CSS Regions
- Exclusions
- Shaders
- Shadow DOM
- Multiple Images in background
- Alpha
- Font-faces
- Animation using Keyframes
- Position:fixed or other positioning important for animations to work
New Tags in HTML5
- New semantic tags - header, footer, nav, section, aside, article
- Multimedia tags - audio/sound,video
- Drawing based tags - canvas, svg
- Form based new tags - Date, slider, time, spinner