HTMl5 and CSS
Comment HTML
1 | <!-- |
Inline CSS
1 | <h2 style ="color: red">CatPhotoApp</h2> |
Use CSS Selectors to Style Elements
1 | <style> |
Style Multiple Elements with a CSS Class
1 | <style> |
Change the Font Size of an Element
1 | <style> |
Set the Font Family of an Element
1 | <style> |
Import a Google Font
1 | <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css"> |
Specify How Fonts Should Degrade
1 | p { |
Add Images to your Website
1 | <img src="https://bit.ly/fcc-relaxing-cat" alt="Author standing on a beach with two thumbs up. "> |
Size your Images
1 | <style> |
Add Borders Around your Elements
1 | <style> |
Add Rounded Corners with a Border Radius
1 | .thick-green-border { |
Make Circular Images with a Border Radius
1 | .thick-green-border { |
Link to External Pages with Anchor Elements
1 | <a href="http://freecodecamp.com"> cat photos</a> |
Nest an Anchor Element within a Paragraph
1 | <p>View more <a href="http://www.freecatphotoapp.com">cat photos</a></p> |
Make Dead Links using the Hash Symbol
1 | <p>Click here for <a href="#">cat photos</a>.</p> |
Turn an Image into a Link
1 | <p>Click here for <a href="#"><img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. "></a></p> |
Create a Bulleted Unordered List
1 | <ul> |
Create an Ordered List
1 | <ol> |
Create a Text Field
1 | <input type="text"> |
Add Placeholder Text to a Text Field
1 | <input type="text" placeholder="cat photo URL"> |
Create a Form Element
1 | <form action="/submit-cat-photo"> |
Add a Submit Button to a Form
1 | <form action="/submit-cat-photo"> |
Use HTML5 to Require a Field
1 | <input type="text" required placeholder="cat photo URL"> |
Create a Set of Radio Buttons
1 | <form action="/submit-cat-photo"> |
Create a Set of Checkboxes
1 | <form action="/submit-cat-photo"> |
Check Radio Buttons and Checkboxes by Default
1 | <form action="/submit-cat-photo"> |
Nest Many Elements within a Single Div Element
1 | <div> |
Set the ID of an Element
1 | <form id = "cat-photo-form" action="/submit-cat-photo"> |
Use an ID Attribute to Style an Element
1 | <style> |
Adjusting the Padding of an Element
1 | <style> |
Adjust the Margin of an Element
1 | <style> |
Add a Negative Margin to an Element
1 | <style> |
Add Different Padding to Each Side of an Element
1 | .green-box { |
Add Different Margins to Each Side of an Element
1 | .green-box { |
Use Clockwise Notation to Specify the Padding of an Element
1 | .green-box { |
Use Clockwise Notation to Specify the Margin of an Element
1 | .green-box { |
Inherit Styles from the Body Element
1 | <style> |
Prioritize One Style Over Another
1 | <style> |
Override Styles in Subsequent CSS
The second declaration will always take precedence over the first. Because .blue-text is declared second, it overrides the attributes of .pink-text
1 | <style> |
Override Class Declarations by Styling ID Attributes
id attribute will always take precedence.
1 | <style> |
Override Class Declarations with Inline Styles
1 | <h1 style="color: white" id="orange-text" class="pink-text blue-text">Hello World!</h1> |
Override All Other Styles by using Important
1 | <style> |
Use Hex Code for Specific Colors
1 | <style> |
Use RGB values to Color Elements
1 | body { |
Responsive Design with Bootstrap
Use Responsive Design with Bootstrap Fluid Containers
- popular Bootstrap responsive CSS framework.
- Bootstrap will figure out how wide your screen is and respond by resizing your HTML elements - hence the name Responsive Design.
1 | <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/> |
Make Images Mobile Responsive
class: image-responsive
1 | <img class="img-responsive thick-green-border" src="https://bit.ly/fcc-running-cats" alt="A cute orange cat lying on its back. "> |
Center Text with Bootstrap
class: text-center
1 | <h2 class="red-text text-center">CatPhotoApp</h2> |
Create a Bootstrap Button
class: btn
1 | <button class="btn">Like</button> |
Create a Block Element Bootstrap Button
1 | <button class="btn btn-block">Like</button> |
Taste the Bootstrap Button Color Rainbow
1 | <button class="btn btn-block btn-primary">Like</button> |
Button Info
1 | <button class="btn btn-block btn-info">Info</button> |
btn-danger
1 | <button class="btn btn-block btn-danger">DELETE</button> |
Use the Bootstrap Grid to Put Elements Side By Side
1 | <div class="row"> |
Use Spans for Inline Elements
1 | <p>Things cats <span class = "text-danger">love:</span></p> |
Create a Custom Heading
1 | <div class="row"> |
Add Font Awesome Icons to our Buttons
1 | <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/> |
Add Font Awesome Icons to all of our Buttons
1 | <div class="row"> |
Responsively Style Radio Buttons
1 | <div class="row"> |
Responsively Style Checkboxes
1 | <div class="row"> |
Style Text Inputs as Form Controls
1 | <input class = "form-control" type="text" placeholder="cat photo URL" required> |
Create a Bootstrap Headline
1 | <h3 class = "text-primary text-center">JQuery Playground</h3> |
House our page within a Bootstrap Container Fluid Div
1 | <div class = "container-fluid"> |
Create a Bootstrap Row
1 | <div class="container-fluid"> |
Split your Bootstrap Row
1 | <div class="container-fluid"> |
Create Bootstrap Wells
1 | <div class="container-fluid"> |
Add Elements within your Bootstrap Wells
1 | <div class="container-fluid"> |
Apply the Default Bootstrap Button Style
1 | <div class="container-fluid"> |
Create a Class to Target with jQuery Selectors
1 | <div class="container-fluid"> |
Add ID Attributes to Bootstrap Elements
1 | <div class="container-fluid"> |
Label Bootstrap Wells
1 | <div class="container-fluid"> |
Give Each Element a Unique ID
1 | <div class="container-fluid"> |
Label Bootstrap Buttons
1 | <div class="container-fluid"> |
jQuery
Learn how Script Tags and Document Ready Work
1 | <script> |
Target HTML Elements with Selectors Using jQuery
jQuery functions start with a $, usually referred to as a dollar sign operator, or as bling.
1 | <script> |
Target Elements by Class Using jQuery
1 | <script> |
Target Elements by ID Using jQuery
1 | $("#target3").addClass("animated fadeOut"); |
Target the same element with multiple jQuery Selectors
1 | <script> |
Remove Classes from an element with jQuery
1 | $("button").removeClass("btn-default"); |
Change the CSS of an Element Using jQuery
1 | <script> |
Disable an Element Using jQuery
jQuery has a function called .prop() that allows you to adjust the properties of elements.
1 | $("#target1").prop("disabled", true); |
Change Text Inside an Element Using jQuery
jQuery also has a similar function called .text() that only alters text without adding tags. In other words, this function will not evaluate any HTML tags passed to it, but will instead treat it as the text you want to replace the existing content with.
1 | $("#target4").html("<em>#target4</em>"); |
Remove an Element Using jQuery
1 | $("#target4").remove() |
Use appendTo to Move Elements with jQuery
moving elements from one div to another.
1 | $("#target2").appendTo("#right-well"); |
Clone an Element Using jQuery
1 | $("#target5").clone().appendTo("#left-well"); |
Target the Parent of an Element Using jQuery
jQuery has a function called parent() that allows you to access the parent of whichever element you’ve selected.
1 | $("#target1").parent().css("background-color","red") |
Target the Children of an Element Using jQuery
1 | $("#right-well").children().css("color","orange") |
Target a Specific Child of an Element Using jQuery
1 | <script> |
Target Even Numbered Elements Using jQuery
1 | $(".target:even").addClass("animated shake") |
Use jQuery to Modify the Entire Page
1 | $("body").addClass("animated hinge"); |