HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
HTML Tutorial

CSS Tutorial

How to include, how incorporate CSS in HTML

One of the main features of CSS is flexibility and the different options it offers to perform the same task. In fact, there are three options for including CSS in an HTML document:
Include CSS in the same HTML document.
Define CSS in an external file.
Include CSS in HTML elements.

1. Include CSS in the same HTML document - How to add CSS to HTML in the same document.

CSS Styles are defined in a specific area of the HTML document. The HTML <style> tag is used and can only be included in the document header (only within the <head> section). This is one way - how to embed CSS in HTML.
Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example - How to add CSS to HTML in the same document</title>
<style type="text/css">
p
{ color: black;
font-family: Verdana;
}
.box1 {
height: 200px;
width: 400px
background-color: green;
font-size: 14px;
}
</style>
</head>
  <body>
<p>TEXT HERE - Include CSS in the same HTML document - How to add CSS to HTML in the same document.</p>
<div class="div-article-script">
<p>Your text here.</p>
Any text here
</div>
</body>
</html>

2. Define CSS in an external file - Another metod - how to include CSS in HTML

In this case, all CSS styles are included in a CSS file that HTML pages link using the <link> tag. A CSS file is nothing more than a simple text file whose extension is .css. You can create all the CSS files that are necessary and each HTML page can link as many CSS files as you need.
If you want to include the styles from the previous example in an external CSS file, you must follow a few steps:
1) A text file is created and only the following content is added:
p {color: black; font-family: Verdana; }, .box1 { height: 200px; width:400px; background-color: green; font-size: 14px; }
2) The text file with the name styles.css is saved. Special attention must be to the file having a .css extension and not .txt
3) The HTML page links the external CSS file using the <link> tag:

Exam

3. Include CSS in HTML elements - another way - how to incorporate CSS in HTML

The last method to include CSS styles in HTML documents is the worst way and the least used, since it has the same problems as the use of <font> tags.

Example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example - Include CSS in HTML elements</title> </head>
  <body>
<p style="color: black; font-family: Verdana;">your text here</p>
</body>
</html>
This way of including CSS directly in the HTML elements is only used in certain situations in which a very specific style must be included for a single specific element.

How to include, incorporate CSS in HTML, How to add CSS to HTML, How to embed CSS in HTML, How to add CSS to a Webpage, Adding external CSS in an HTML file How to include, how to incorporate CSS in HTML - css tutorial

3185. CSS Margin, top, bottom, left, righ, auto, css tutorial
CSS Margin, top, bottom, left, righ, auto css tutorial
https://www.agernic.com/css-tutorial/css-margin-top-bottom-left-righ-auto.html

3013. CSS Text Style - Text Font Size - Text Align, css tutorial
CSS Text Style - Text Font Size - Text Align css tutorial
http://www.agernic.com/css-tutorial/css-text-style-font-size-and-text-align.html

3184. CSS link color - CSS link href HTML - Link without underline, css tutorial
CSS link color - CSS link href HTML - Link without underline css tutorial
https://www.agernic.com/css-tutorial/css-link-color-css-link-href-html-link-without-underline.html

3183. CSS Introduction Tutorial, css tutorial
CSS Introduction Tutorial css tutorial
https://www.agernic.com/css-tutorial/css-introduction-tutorial.html

667. CSS tutorials - w3resource

https://www.w3resource.com/css/CSS-tutorials.php

2804. CSS background, Color, Background Image, css tutorial
CSS background, Color, Background Image css tutorial
http://www.agernic.com/css-tutorial/css-background-color-image-css-tutorial.html

Your add here
How to get PHP errors to display?
How to prevent sql injection in php mysqli
How do I get PHP errors to display - PHP error_reporting()
mysql_query(): The mysql extension is deprecated and will be removed i
Function eregi_replace() is deprecated in php - How to fix
PHP delete an element from an array
Uncaught Error: Call to undefined function MYSQL_NUM_ROWS() in
Deprecated: mysql_connect() mysql extension is deprecated and will be
mysqli_fetch_array() expects parameter 1 to be mysqli_result boolean g
SQL IN Operator - example
SQL BETWEEN Operator
SQL like syntax and example
SQL WHERE AND & OR multiple conditions
SQL create table primary key autoincrement
PHP mysqli_connect () Function
SQL COUNT(), AVG() and SUM() Functions
Display data from SQL database with MySQLi into php - html table
SQL CREATE DATABASE - example
SQL mysql order by columns, by date, by asc, by desc, random with PHP
PHP mysqli_query() Function - mysqli query
SQL delete row - SQL delete table
SQL update - SQL update select
Insert into SQL - Insert into table SQL - Insert data in sql
Login in PHP - simple login script with PHP MYSQL