Learn CSS from the Best Tutors
Search in
There are different ways to write CSS code
1) external on a seperate file with .css extension
2) Internal as part of the head section of the HTML page
3) embeded as part of the HTML tag
The easiest way is to have an external CSS file and then to link it.
!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="mystyle.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
here you have both the HTML file and CSS file in the same folder .
for example the mystyle.css file can have the below code\
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
we use this if we want the whole website to be consistent, so we link to each and every web page .
An internal style sheet may be used if one single HTML page has a unique style.
The internal style is defined inside the <style> element, inside the head section.
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
An inline style may be used to apply a unique style for a single element.
To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property.
read less
Related Questions
Why is HTML is used in Web Application?
Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com
Ask a QuestionRecommended Articles
Why Should you Learn HTML
Since the world today is ruled by the Internet, everyone desires to build a website for either business or personal interests. HTML or Hyper-text Mark-up Language is a globally standardized language which used to format web pages. By using HTML, the appearance of text, links, images and almost every part of a web page could...
Skills Required to Become a Front End Web...
Today, no business can exist without having its own website to interact with its customer base. Having a website is no more restricted to the big MNCs. With the advancement in technology and global business, even the small enterprises are spending on having their own websites and development teams. The person works on web...
Learn Hadoop and Big Data
Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...
Learn Microsoft Excel
Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...
Looking for CSS Training?
Learn from the Best Tutors on UrbanPro
Are you a Tutor or Training Institute?
Join UrbanPro Today to find students near youThe best tutors for CSS Classes are on UrbanPro
The best Tutors for CSS Classes are on UrbanPro