How-to articles, tricks, and solutions about HTML

How to Set the Table Column Width Regardless of the Text Amount in its Cells

Sometimes, when the text in one of the cells of the column is too long, the column’s width change. Read this snippet to find out how to overcome this problem.

How to Set the Width of the Table Column

In this tutorial, we’ll show how you can set the width of the HTML table column. For that purpose, you need to use some CSS, particularly the width property.

How to Stretch a Text with CSS

In this snippet, we’ll show how to stretch a text horizontally or vertically using CSS. For that, you can use the CSS transform property set to the “scale”.

How to Strip HTML from a String in JavaScript

In this tutorial, you will find several approaches to strippingan HTML from a sting in JavaScript easily. Get the codes and explanations right away.

How to Style Even and Odd List Items

In this snippet, we’re going to demonstrate how to style the even, odd, or both the even and odd items of an unordered list. See examples with each of them.

How to Style Input and Submit Buttons

In this snippet, you will find out how to style input and submit buttons easily. Use various CSS properties to achieve this goal. Read the snippet and try examples.

How to Style the Selected Label of a Radio Button

In this snippet, learn how you can style the selected label of a radio button. For that, you need to use the CSS :checked pseudo-class and some properties.

How to Test If a Checkbox is Checked with jQuery

In this tutorial, you will find several jQuery methods that are used for testing whether the checkbox is checked based on the different versions you use.

How to Truncate Multi-Line String with Pure CSS

It's a common problem to truncate a multi-line string. In this snippet, we'll show how to do it with CSS properties. You can also use CSS pseudo-elements.

How to Turn a Rectangular Image into a Cropped Square Image with CSS

In this snippet, we’ll show how you can turn a rectangular image into a cropped square. We’ll use CSS and turn an image into a square without distorting it.

How to Use the "required" Attribute on the <select> Element in HTML5

The “required” attribute works only on empty values. In this snippet, we’ll show how to apply it to the HTML <select> element. Read and find some examples.

How to Use the "required" Attribute with the Radio Input Field

Read this snippet to find out how you can use the “required” attribute with the radio Input field. Here, you can also find an example and try it yourself.

How to Use the HTML <fieldset> Tag

In this tutorial, you will find some examples of using the HTML <fieldset> element. Besides, you can find out why in general we need the <fieldset> element.

How to Use the HTML accept Attribute

In this tutorial, we’ll explain what is the HTML accept attribute and why it is used. Use this attribute to specify file types the user is allowed to choose from.

How to Validate an E-mail Using JavaScript

Read this tutorial and learn a fast and easy solution to the issue of validating an email using JavaScript. Also, you will read about what the email is.

How to Vertically Align a Text Next to the Image

A common question is how to align text next to an image vertically? Read this snippet and learn to do it step by step, as well as try different examples.

How to Vertically Align a Text Within a <span> Tag to the Center

On this page, we’ll demonstrate how to vertically align a text within an HTML <span> element. Use the CSS align-items, text-align, or vertical-align properties.

How to Vertically Align an Image Within a Div With Responsive Height

In this snippet, we will demonstrate some techniques of vertically aligning an image within an HTML <div> element with responsive height. Read and try examples.

How to Vertically Align Two <div> Elements with Bootstrap

In this tutorial, learn how you can vertically align two <div> elements with Bootstrap. On this page, we’ll demonstrate some examples for Bootstrap 3.4.1 and 4.5.0.

How to Vertically Center a <div>

This snippet will help you to align a <div> element for all browsers vertically. You will learn to do it step by step with our examples and explanations.

How to Vertically Center Inline (Inline-Block) Elements

On this page, you’ll learn how to vertically align inline (inline-block) elements. Try examples with many different methods (CSS padding, vertical-align, etc.).

How to Wrap a Long String Without any Whitespace Character

In this snippet, we’ll demonstrate how to wrap a long string without any whitespace character. Use the CSS word-wrap property with the “break-word” value.

How to Wrap Text in a <pre> Tag with CSS

The <pre> tag inserts a preformatted text into an HTML document. Since the <pre> tag doesn’t support wrapping, we’ll show how to do it with the help of CSS.

How to Wrap the Content of a Table Cell

In this tutorial, we’ll demonstrate how to wrap the content of a table cell. For that, you need to use either the CSS word-wrap or word-break property.

How to Wrap Words in a <div> Tag with CSS

If you’ve faced the situation when you need to wrap long words in a <div>, use the white-space property with the “pre-wrap” value and word-wrap property.