- Introduction To HTML
- HTML Elements And Tags
- Text Formatting And Styling
- Images And Multimedia
- Hyperlinks And Anchors
- Tables And Forms
- HTML5 Semantic Elements
- Responsive Design And Meta Tags
- Embedded Content And APIs
- Canvas
- Drawing Basic Shapes
- Working With Text And Fonts
- Working With Images
- Canvas Transformations
- Working With Animation
- Interactivity And Event Handling
- Canvas Advanced
- Introduction To SVG
- SVG Gradients And Patterns
- SVG Transformations And Transitions
- SVG Filters And Effects
- SVG Paths And Bezier Curves
- SVG Icons And Illustrations
- SVG Responsive Design And Accessibility
Text Formatting and Styling
Applying Text Formatting With Tags Such As Strong , Em, U, And S )
1. (<strong>) Tag:
The <strong>
tag is used to highlight text as important or strongly emphasized. It typically renders as bold text by default, but its semantic meaning is to convey importance rather than just bold styling.
Example:
In this example, the word "important" is highlighted as important within the paragraph.
2. ' <em>' Tag:
The <em>
tag is used to italicize text, indicating emphasis. Italicized text can signify stress, importance, or a change in tone.
Here, the word "very" is italicized for emphasis within the sentence.
3.' <u>' Tag:
The <u>
tag is used to underline text. It's commonly used to indicate hyperlinks, but it can also be used for other instances where underlining is necessary.
Example:
The word "underlined" in the paragraph is visually underlined.
4. '<s>' Tag:
The <s>
tag is used to create a strikethrough effect on text, indicating that the text has been deleted or is no longer valid.
Example:
The word "strikethrough" is displayed with a line through it, indicating that it's no longer valid or relevant.
Importance and Usage:
- Semantic Meaning: These tags carry semantic meaning, helping assistive technologies and search engines understand the structure and emphasis of text.
- Accessibility: Proper use of these tags improves accessibility for users who rely on screen readers or have visual impairments.
- Clarity: Text formatting with these tags enhances readability and clarity, making important information stand out.
- Styling Flexibility: While these tags have default styling (like bold, italic, underline, and strikethrough), their appearance can be customized using CSS for design purposes.
This sentence demonstrates the combined use of <strong>, <em>, <u>
, and <s>
tags for different types of text formatting within a paragraph.
Practice Excercise Practice now
Using Inline And Block-level Elements For Text And Content Organization
Inline Elements:
(<span>) Element:The <span>
element is an inline container used for styling specific parts of text or content.
Explanation: In this example, the word "highlighted" is styled using the <span> element to change its color to red. (<a>) Element (Hyperlink):
The <a>
element is used to create hyperlinks to other web pages or resources.
Explanation: The <a>
element creates a hyperlink to the specified URL, making the word "website" clickable.
The <strong>
and <em>
elements are used for semantic text emphasis.
Explanation: The <strong>
element makes the word "Important" bold, while the <em>
element italicizes the word "urgent" for emphasis.
The <img>
element is used to insert images into web pages.
Explanation: The <img>
element displays the image "logo.png" inline within the paragraph.
Block-Level Elements:
<div> Element:
The <div>
element is a generic block-level container used for grouping and styling content.
<h2>Section Title</h2>
<p>This is a block of content within a div element.</p>
</div>
Explanation: The <div>
element creates a block-level container with a background color and padding, containing a heading and a paragraph.
The <p> element is used to define paragraphs of text.
Example:<p>This is the second paragraph.</p>
Explanation: Each <p> element starts a new block-level paragraph.
(<h1> to <h6> ) Elements (Headings):
The <h1>
to <h6>
elements are used to create headings of varying levels.
<h2>Subheading 1</h2>
<h3>Subheading 2</h3>
Explanation: Each heading element represents a different level of importance and creates block-level headings.
(<ul> and <ol>) Elements (Lists):The
<ul>
(unordered list) and <ol>
(ordered list) elements create lists of items.Example:
<li>Item 1</li>
<li>Item 2</li>
</ul>
Explanation: The <ul>
element creates a bulleted list, and each <li>
item is a block-level list item.
- Combining Inline and Block-Level Elements:
- Mixing Inline and Block-Level Elements:
<p>This is a <strong>bold</strong> paragraph.</p>
<a href="https://example.com">Visit our website</a>
</div>
Explanation: The <div>
element contains both a block-level <p>
paragraph and an inline <a>
hyperlink.
Example:
<h2>Main Heading</h2>
<p>This is a <span style="color: blue;">blue</span> paragraph.</p>
</div>
Explanation: The <span>
element is nested inside a block-level <p>
paragraph within a <div>
container.
- Importance of Using Inline and Block-Level Elements:
- Structure: Block-level elements help organize content into sections, while inline elements allow fine-grained styling within blocks.
- Semantic Meaning: Proper use of block-level and inline elements conveys the structure and meaning of content to browsers and assistive technologies.
- Styling Flexibility: Inline elements are useful for applying specific styles to individual parts of text, while block-level elements structure the overall layout of a page.
Practice Excercise Practice now
Introduction To CSS For Styling HTML Elements
Understanding CSS:
CSS (Cascading Style Sheets) is a style sheet language used to define the presentation and layout of HTML documents. It allows web developers to control the appearance of web pages, including colors, fonts, spacing, and positioning of elements. CSS works by selecting HTML elements and applying styles to them.
Basic Structure of CSS:
CSS rules consist of selectors and declarations:
- Selectors: Selectors target HTML elements to apply styles. They can target specific elements, classes, IDs, attributes, or even combinations of these.
- Declarations: Declarations define the styles to be applied, such as color, font size, margin, padding, etc. They are enclosed within curly braces {} and separated by semicolons ;.
Linking CSS to HTML:
CSS can be linked to HTML documents in three main ways:
External Style Sheet:
This method links an external CSS file (styles.css) to the HTML document.
Internal Style Sheet:/* CSS code here */
</style>
This method includes CSS code directly within the <style>
tags in the HTML document.
Inline styles are applied directly to HTML elements using the style attribute.
CSS SelectorsElement Selector:
color: red;
}
Targets all <p>
elements and sets their text color to red.
background-color: yellow;
}
Targets elements with class="highlight" and sets their background color to yellow.
ID Selector:font-size: 24px;
}
Targets the element with id="header" and sets its font size to 24 pixels.
Attribute Selector:border: 1px solid black;
}
Targets <input>
elements with type="text" and applies a black border.
color: blue;
}
Sets the text color of <h1>
elements to blue.
Font Property:
font-family: Arial, sans-serif;
}
Sets the default font family for the entire document.
Background Property:background-image: url('background.jpg');
background-size: cover;
}
Applies a background image to elements with class .jumbotron and covers the entire element.
Margin and Padding:margin: 10px;
padding: 20px;
}
Sets margin and padding values for elements with class .box.
Positioning:
position: fixed;
top: 0;
left: 0;
width: 200px;
}
Fixes the position of .sidebar to the top left corner and sets its width to 200 pixels.
CSS Box Model:The CSS box model describes the space occupied by an element, including content, padding, border, and margin.
- Content: Actual content area where text or images are displayed.
- Padding: Space between the content and the border.
- Border: Boundary around the padding.
- Margin: Space outside the border, separating elements.
Example:
Let's consider a simple example to illustrate CSS styling:
HTML:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Welcome to CSS Styling</h1>
<p class="intro">This is a CSS example.</p>
<div id="container">
<p>This is a styled paragraph.</p>
</div>
</body>
</html>
css
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}
h1 {
color: blue;
}
.intro {
font-size: 18px;
}
#container {
background-color: #fff;
padding: 20px;
border: 1px solid #ccc;
margin: 10px;
}
In this example:
- The
<h1>
element's text color is set to blue. - Paragraphs with class .intro have a font size of 18 pixels.
- The
<div>
with ID container has a white background, padding, border, and margin.
CSS is a powerful tool for styling HTML elements, offering control over appearance, layout, and presentation. Understanding CSS selectors, properties, and the box model is essential for creating visually appealing and well-structured web pages. By linking CSS to HTML and applying styles selectively, developers can create engaging and responsive user interfaces.
Practice Excercise Practice now
Products
Partner
Copyright © RVR Innovations LLP 2024 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP