Codess For HTML and Css
Codess For HTML and Css
Tag HTML
Purpose Example
<html>…</html> This tag is used to specify that the<html>
webpage is written in html, it is ……
used at the very first and last line……
of the code. </html>
<head>…</head> This tag includes the title and the <head>
links to JS and CSS scripts. <link ….>
<title>…. </title>
</head>
<body>…</body> Everything user sees on the <body>
webpage is written inside this tag. <h1>…. </h1>
</body>
<title>…</title> This tag contains the name of the <title>Cheat sheet</title>
webpage.
<link> It is used to link JS and CSS <link rel=” stylesheet”
scripts. href=”style.css”>
<h1…h6>…</h1… 6 different ways of writing a <h1>Cheat sheet</h1>
h6> heading, h1 is the largest while h6 <h2>HTML</h2>
is the smallest.
<div>…</div> It is a block-level element, it is <div>
used as a container for html <h1>…</h1>
elements. </div>
<span>…</span> It is an inline element, it is also <span>
used as a container for html <h1>…</h1>
elements. </span>
<p>…</p> It is used to write paragraphs. <p>HTML stands for Hyper
Text Markup Language</p>
<hr> It divides the elements by <hr>
drawing a horizontal line. (doesn’t have an ending tag)
<img> This tag is used to display images <html>
on webpage. <body>
<img src=” html.png”>
The URL where the image is </body>
src=”url” located on the drive/web. </html>
<a href=”…”>…</a> <a href=”…”>…</a> <a href=” youtube.be”>
id=”…” Id is used to identify one element. <div id=” htmlid”>
CSS
Tag Purpose Example
text-align This tag is used to align body {
the text in centre, left, text-align: centre;
right or bottom. }
font-family This tag specifies the font body {
of the text. font-family: arial;
}
color This tag specifies the body {
colour of the text. color: red;
}
font-style This tag allows you to body {
make your text italic, font-style: italic;
normal or oblique. }
font-weight This tag sets the body {
thickness/boldness of the font-weight: bold;
text. }
font-size This tag sets the size of body {
the font. font-size: 50px;
}
border This tag makes a border body {
around the specified border: dotted red;
area. }
border-radius This tag is rounds the .circle {
corners of an element. border-radius: 50%;
}
background/background- This tag changes the body {
color background-colour. background: red;
}
background-image: This tag is used to set an body {
url(“image.jpg”); image as background. background-image:
url(”bird.jpg”);
}
background-image: linear- This tag is used to set a body {
gradient linear gradient as background-image: linear-
background gradient(to
top/bottom/left/right,blue,red);
}
margin This tag sets a margin body {
around the area. margin: 20px
}
width and height This tag sets height and img {
(used for images mostly) width of the element. width: 50% or 30px;
height: 100px;
}
#id (when id needs to be This tag gives properties #cssid {
styled) to the mentioned id. color: white;
}
.class (when class needs to This tag gives properties .cssclass {
be styled) to the mentioned class. color: white;
}
padding This tag makes space body {
inside the element. padding: 20px;
}
line height This tag makes space body {
between lines of the line-height: 8px;
sentence. }
display This tag sets the display span {
behaviour of an element. display: inline-block;
}
text-decoration This tag is used to a{
decorate an element. text-decoration: none;
}
vertical-align The vertical-align img.a {
property in CSS controls vertical-align: baseline;
how elements set next to }
each other on a line are
lined up. img.b {
vertical-align: text-top;
}
img.c {
vertical-align: text-bottom;
}
img.d {
vertical-align: sub;
}
img.e {
vertical-align: super;
}
float The float CSS property img {
places an element on the float: left;
left or right side of its }
container, allowing text
and inline elements to
wrap around it. Floated
elements are taken out of
the normal document
flow and do not take up
space. So it practically
does not have any
width/height.
overflow: hidden; Adding overflow: hidden; div {
triggers a new block overflow: hidden;
formatting context that }
prevents <ul> from collapsing
when it has floated children.
!important !important in CSS means that body {
all the previous styles on an background-color: blue;
element are to be ignored, background-color:red;!important;
and the style denoted by !
important is to be applied.
background-color:white;
position: sticky; Position: sticky will stick the .class {
element to a position position:sticky;
specified when we scroll }
up/down the web page.
a:link This tag is used to specify a:link{
the property of the link. color: red;
}
a:visited This tag is used to specify a:visited{
the property of the link color: red;
visited. }
JavaScript
Bootstrap