Skip to main content

Learn details About CSS details. How To Use CSS in HTML?

                                     About CSS

 In this article we will know "What is CSS ?". Different people do different types of work like someone doing their own business, someone doing online jobs and someone working inside a company. 

    Whether the work is big or small, a person has to work hard in every work, only then  he can earn money. In the same way, a Web Developer also earns money by working hard through the Internet. If you thinking you will start web design and coding first of all you should know basic of html and CSS. It's necessary to learn html and CSS. Every website has using html and CSS so we will learn here what is  CSS and how it's works. So let's go πŸ‘‰πŸ‘‰



                                                
                                                  What Is CSS?

    
    CSS stands for Cascading Style Sheets, CSS describes how HTML elements are to be displayed on    screen, paper, or in other media , CSS saves a lot of work. It can control the layout of multiple web      pages all at once   External stylesheets are stored in CSS files.
 Must CSS use for the presentation of Web pages, including colors, layout, and fonts. It allows one to adapt the presentation to different types of devices, such as large screens, small screens, or printers. 
There are three ways to apply CSS code to our site. The first is by linking to an external file. This is the recommended method. To do linking, you need to write your CSS rules in a separate text file and save it
with a . CSS extension. The syntax for adding the rules to your HTML code is :

<link rel="stylesheet" type="text/css" href="style.css">

      You add the <link> tag to the head element, between the <head>...</head>   tags. The first two attributes rel and type tell the browser that this is a CSSstylesheet. You do not need to modify them. The last attribute href is where you specify the path to the CSS file that you want to link to. A CSS file is simply a file that contains CSS rules, without any HTML tags. An example is shown below. Don’t worry if the code does not make sense to you, we’ll cover them very soon.
body {
margin: 0;
background-color: green;
}
Save this code as “style.css” in the same folder as the .html file. You can then
use the <link> tag above to link this CSS file to your HTML file.
The second method to add CSS rules to our site is to embed the code directly
into our HTML source code, within the head element. This is done with the
<style> tag. An example is shown below. The embedded CSS code starts after
the <style> start tag and ends before the </style> end tag.
<head>
<style>
div {

color: blue;
width: 100px;
height: 200px;

}
</style>
</head>


                                                  Syntax Of a CSS Rules 

          Now that we know how to apply CSS rules to our HTML files, let’s move on to
learn some actual CSS code. The first thing to learn about CSS is its syntax,
which is relatively straightforward. The syntax is:


selector { property : value; property : value; property : value; }
For instance, if you want to style the contents inside a <div> tag, you write the
rule as
div {
background-color: green;
font-size: 12px;
}
The first word div is the selector. It tells the browser that the set of rules inside
the curly brackets { } applies to all elements with the <div> tag.
Inside the curly brackets, you write all your declarations. You start by declaring
the property that you want to set (background-color in the first declaration),
followed by a colon (:). Next, you give the value that you want (green in this
case). Finally, you end each declaration with a semi-colon (;).
Indentation and line breaks do not matter in CSS. You can also write your
declarations like this:
div { background-color: green; font-size: 12px; }

                                      

                                            How To Select Class and Id?

   There are basically two ways to do it. The first method is to use the id attribute. In your HTML document, instead of just using the <div> tag, you can add an id  attribute to it. For instance, you can write

<div id=”para1”>

Some text.

</div>

<div id=”para2”>

More text.

</div>

In our CSS code, we can then select the respective id by adding a # sign in front

of the id name. An example is shown below:

div {

background-color: green;

}

#para1

{

font-size: 12px;

}

#para2

{

font-size: 14px;

}

    We won’t go into details about how to calculate the specificity of a selector. The
main point to remember is that an id is considered to be more specific than a
class, and a class more specific than an element. Let’s consider the code
below:
div { font-size: 10px; }
#myId { font-size: 12px; }
.myClass { font-size: 14px; }
<div id=”myId” class=”myClass”>Some text</div>
Since the <div> element has class=”myClass” and id=”myId”, all three rules
div, #myId and .myClass will apply to the <div> element. However, as id has
the highest precedence, “Some text” will be displayed with a font size of 12px.
In addition, another point to note about specificity is that the more detailed your
selector, the higher the precedence. For instance, div#myId has a higher
precedence than #myId. This is because div#myId is considered to be more
detailed as it tells us that myId is an id of the div element. In the sample code
below, the color yellow will be applied.

div { color: red; }

div#myId { color: yellow; }

#myId { color: blue; }

.myClass { color: green; }

<div id=”myId” class=”myClass”>Some text</div>


                                                                             CSS Box Model

       All elements in CSS are treated as boxes. CSS boxes consist of margins, borders,
padding, and the actual content as shown below.

                                      

                                                        


The thick black line is the border. Within the border is the padding and the actual
content. Outside the border is the margin of the box. The thickness of the
padding, border and margin can all be modified with CSS. To understand how
this box model works, let’s analyze the code below. You can download this code
at http://learncodingfast.com/css.


<!doctype html>
<html>
<head><title>Chapter 4 - CSS Box Model</title>
<style type="text/css">
#box1 {
margin: 20px;
padding: 10px;
border: 5px solid black;
width: 100px;
height: 100px;
text-align: justify;
float: left;
}
#box2 {
margin: 20px;
padding: 50px;
border: 5px solid black;
width: 100px;
height: 100px;
text-align: justify;
float: left;
}
</style></head>
<body>
<div id="box1">Learn CSS in One Day and Learn It Well. CSS is easy.
</div>
<div id="box2">Learn CSS in One Day and Learn It Well. CSS is easy.
</div>


<p>Welcome to TechnoTips</p>


</body>
</html>
If you run this code, you’ll get the boxes below. The gibberish text beside and
below the boxes is added to show the margin.


                                                              Text and Font

         Text and font properties in CSS are used to format the appearance of words and text on a webpage. The font property is concerned with how the characters look, such as whether they are ‘fat’ or ‘thin’, ‘big’ or ‘small’, and what font type to use. The text property is used to style everything else. In this chapter, we’ll be covering the text and font properties commonly used.

Font Properties

font-family

The font-family property is used to set the font type.

There are three main categories of font types: serif, san serif and monospace.

Serif fonts have a small line at the end of some characters.

   Start with a more specific font (such as “Times New Roman”) and end with a generic font family. If the font name is more than one word, quotation marks should be used.

Example:

font-family: "Times New Roman", Times, serif;

font-style: italic;

The font-weight property is the counterpart of font-style. While font-style
is used to specify italic text, font-weight is used to specify bold text.
Commonly used values include normal, bold, bolder and lighter.
Alternatively, you can also specify the thickness of the characters using numbers
in multiples of 100, from 100 (thinnest) to 900 (thickest). 400 is the normal
thickness, and 700 is the same as bold.

                                                  text-decoration

The text-decoration property is mainly used to specify whether the text should
be decorated with a line. The commonly used values are none (i.e. just normal
text, no decoration), underline, overline (a line above the text) and line-
through (a line through the text).
This property is commonly used to remove underlines from hyperlinks. By
default, most browsers will display hyperlinks in blue, with an underline. You
can use the code text-decoration: none; to remove the underline.
Example:
text-decoration: none;


                                                           CSS Links


        Hyperlinks can be styled using any of the CSS properties discussed in previous
chapters. You can style the background color using the background-color
property. This will give the link a highlighted appearance. You can also use the
text and font properties covered in Chapter 8 to change the font size, font style,
text color, text decoration etc.
In addition, we can choose to style hyperlinks based on the state they are in.
Links can be in one of four states:
link (an unvisited link)
visited (a visited link)
hover (when the user mouses over it), or
active (when the link is clicked).
To specify the state, we write a:link, a:visited, a:hover or a:active. You
should always specify the 4 states in the order above.
Examples:
a {
text-decoration: none;

}
a:link {
color: #0000FF;
}
a:visited {
color: #00FF00;
}
a:hover {
color: #FFFF00;
}
a:active {
color: #FF00FF;
}
For More Information Please Visit My Youtube Channel And watch My Videos.

                                                          THANK YOU

Comments

Popular posts from this blog

Best Router Backup In Nepal | WiFi Router Battery UPS | Use Wifi In Power Cut! |

   In This Video I explain about Wifi Router backup So please watch and know everything-                               In this Article I'm talking about UPS Adapter . WIFI routers are not able to run during a power cut. All work gets halted during power cut due to this. This can also be very frustrating. UPS Batteries are available which can directlty be connected to the wifi router so in power cut it doesn’t turn off. If no inverter is installed in your home and you face WiFi disconnection during power cut then this video is for you. It can give upto 5-7 hours of battery backup and support 12V 2A. how to use without power WIFI ? where we can find router backup online ? How to Buy WIFI backup UPS Adapter ? How much price for this router? Where we can find this? How to use UPS Adapter ? How long working? #UPS ADAPTER IN NEPAL Router UPS for uninterrupted Inte...

Learn programming on coursera

  Coursera Inc.  ( / k Ι™r ˈ s Ι› r Ι™ / ) is an American  massive open online course  provider founded in 2012 by  Stanford University  computer science professors  Andrew Ng  and  Daphne Koller . Coursera works with universities and other organizations to offer online courses, certifications, and degrees in a variety of subjects. According to CNBC "more than 150 universities offered upwards of 4,000 courses through Coursera, which features over two dozen degree programs at prices that are lower than many in-person school offerings.

What Is Zoom Application ? How To Use Zoom ?

About Zoom The Best Video Meeting App is Zoom. Zoom for reliable, large video calls. In this article I will explain You in this questions: 1.What Is Zoom? 2.How to use for Online class and meetings? 3.How to use zoom apps? 4.How many peoples can join? 5.It's Free Or Paid? Mobile- https://play.google.com/store/apps/de... Laptop- https://zoom.us/download Video conferencing platform ZOOM has become a household name after enjoying a breakout year, in large part due to the pandemic and rise of remote working. It's free and easy for use and grow your business and earn money online. More than 100 peoples can join. It's used primarily by businesses to host meetings with remote colleagues and clients, but Zoom is an equally useful tool for keeping in...