-
HTML Choosing Editors
-
HTML Basic Structure
-
HTML Head
-
HTML Element
-
HTML Attribute
-
HTML Headings
-
HTML Paragraphs
-
HTML Style
-
HTML Formatting
-
HTML Colors
-
HTML CSS
-
HTML Comments
-
HTML Links
-
HTML Images
-
HTML Table
-
HTML List
-
HTML Block and Inline
-
HTML Class & Id
-
HTML iFrames
-
HTML JavaScript
-
HTML File Paths
-
HTML Layout
-
HTML Responsive
-
HTML Style Guide
-
HTML Forms
HTML CSS
HTML CSS are used to control the presentation and appearance of web page content. Styles allow you to define how elements are displayed, such as their colors, fonts, sizes, spacing, and more. Styles make your web page visually appealing and help create a consistent look and feel.
Inline Styles
One way to apply styles to HTML elements is by using inline styles. Inline styles are defined directly within the HTML element using the `style` attribute. Here’s an example:
<p style=”color: blue; font-size: 16px;”>This is a blue, 16px text.</p>
In this example, the `style` attribute is used to set the text color to blue and the font size to 16 pixels for the `<p>` element.
Internal Styles
Internal styles are defined within the `<style>` element in the `<head>` section of an HTML document. They apply to multiple elements on the page. Here’s an example:
In this example, the internal style sets the text color to green and the font size to 18 pixels for all `<p>` elements on the page.
External Styles
External styles are defined in separate CSS (Cascading Style Sheets) files and linked to the HTML document using the `<link>` element in the `<head>` section. External styles allow you to maintain a consistent look across multiple pages. Here’s an example:
Create a file named `styles.css` with the following content: |
p { |
Then, link it to your HTML document: |
<!DOCTYPE html> |
In this example, the external style in `styles.css` sets the text color to red and the font size to 20 pixels for all `<p>` elements on the page.
HTML styles give you the flexibility to control the visual aspects of your web pages, ensuring they look and feel the way you want them to.