• Home
  • Jobs
  • Courses
  • Certifications
  • Companies
  • Online IDE
  • Login
  • Signup
MYTAT
  • Home
  • Jobs
  • Courses
  • Certifications
  • Companies
  • Online IDE
  • Login
  • Signup
HTML
  • 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
  • Home
  • Courses
  • HTML
  • Text Formatting And Styling

Text Formatting and Styling

Previous Next

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:
<p>This is <strong>important</strong> information.</p>

Try it now

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.

Example:
<p>This statement is <em>very</em> important.</p>

Try it now

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:
<p>This is <u>underlined</u> text.</p>

Try it now

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:
<p>This text is <s>strikethrough</s>.</p>

Try it now

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.
Combination Example:
<p><strong>This</strong> is an <em>example</em> of <u>combined</u> text formatting with <s>multiple</s> tags.</p>

Try it now

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.

Example:
 
<p>This is <span style="color: red;">highlighted</span> text.</p>

Try it now


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.

Example:
<p>Visit our <a href="https://example.com">website</a> for more information.</p>

Try it now

Explanation: The <a> element creates a hyperlink to the specified URL, making the word "website" clickable.

(<strong> and <em>) Elements:

The <strong> and <em> elements are used for semantic text emphasis.

Example:
<p><strong>Important:</strong> This is an <em>urgent</em> message.</p>

Try it now

Explanation: The <strong> element makes the word "Important" bold, while the <em> element italicizes the word "urgent" for emphasis.

(<img>) Element (Inline Image):

The <img> element is used to insert images into web pages.

Example:
<p>Welcome <img src="logo.png" alt="Logo"> to our website.</p>

Try it now

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.

Example:
<div style="background-color: #f1f1f1; padding: 10px;">
  <h2>Section Title</h2>
  <p>This is a block of content within a div element.</p>
</div>

Try it now

Explanation: The <div> element creates a block-level container with a background color and padding, containing a heading and a paragraph.

(<p>) Element (Paragraph):

The <p> element is used to define paragraphs of text.

Example:
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>

Try it now

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.

Example:
<h1>Main Heading</h1>
<h2>Subheading 1</h2>
<h3>Subheading 2</h3>

Try it now

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:
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>

Try it now

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:
Example:
<div>
  <p>This is a <strong>bold</strong> paragraph.</p>
  <a href="https://example.com">Visit our website</a>
</div>

Try it now

Explanation: The <div> element contains both a block-level <p> paragraph and an inline <a> hyperlink.

Nested Elements:

Example:
<div>
  <h2>Main Heading</h2>
  <p>This is a <span style="color: blue;">blue</span> paragraph.</p>
</div>

Try it now

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:
<link rel="stylesheet" href="styles.css">

This method links an external CSS file (styles.css) to the HTML document.

Internal Style Sheet:
<style>
  /* CSS code here */
</style>

This method includes CSS code directly within the <style> tags in the HTML document.

Inline Styles:
 
<p style="color: blue; font-size: 16px;">Styled paragraph</p>

Inline styles are applied directly to HTML elements using the style attribute.

CSS Selectors

Element Selector:
p {
  color: red;
}

Targets all <p> elements and sets their text color to red.

Class Selector:
.highlight {
  background-color: yellow;
}

Targets elements with class="highlight" and sets their background color to yellow.

ID Selector:
#header {
  font-size: 24px;
}

Targets the element with id="header" and sets its font size to 24 pixels.

Attribute Selector:
input[type="text"] {
  border: 1px solid black;
}

Targets <input> elements with type="text" and applies a black border.

CSS Properties and Values:
 
h1 {
  color: blue;
}

Sets the text color of <h1> elements to blue.


Font Property:
body {
  font-family: Arial, sans-serif;
}

Sets the default font family for the entire document.

Background Property:
.jumbotron {
  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:
.box {
  margin: 10px;
  padding: 20px;
}

Sets margin and padding values for elements with class .box.


Positioning:
.sidebar {
  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:
 
<!DOCTYPE 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>

Try it now


css
body {
  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.
Conclusion:

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

Previous Next
COMPANY
  • About us
  • Careers
  • Contact Us
  • In Press
  • People
  • Companies List
Products
  • Features
  • Coding Assessments
  • Psychometric Assessment
  • Aptitude Assessments
  • Tech/Functional Assessments
  • Video Assessment
  • Fluency Assessment
  • Campus
 
  • Learning
  • Campus Recruitment
  • Lateral Recruitment
  • Enterprise
  • Education
  • K 12
  • Government
OTHERS
  • Blog
  • Terms of Services
  • Privacy Policy
  • Refund Policy
  • Mart Category
Partner
  • Partner Login
  • Partner Signup

Copyright © RVR Innovations LLP 2025 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP