To emphasize some particularly important elements of the site, it would not hurt to use all kinds of CSS styles and properties. Of course, you don’t have to worry too much about the text and highlight it, for example, in bold or italics, change the background or make a frame around the text. But one of the presented methods is not always suitable. Let's say you have a text that needs to be divided due to the specifics of its semantic load. This is where HTML and CSS properties come to the rescue.

How to make a line in text using CSS

To implement our plans, we will need to contact style.css file, having written in it the corresponding property border. This will cause a line to appear above, below or on a specific side of the text. In turn, there are several properties responsible for displaying the line, namely:

- border-top– a horizontal line located above the text;

- border-right– a vertical line located to the right of the text;

- border-bottom– a horizontal line located below the text;

- border-left– vertical line located on the left.

How to make a line in html

Using CSS properties you can specify all the necessary values ​​by editing the HTML code. To do this, you need to go to the administrative part of the site. Select one of the published materials, switch text editor into HTML code editing mode and add CSS properties. A sample can be seen below.



How to make a dotted or straight line?



By specifying these properties, will you be able to emphasize the importance of the material being presented, paragraph or heading?




Brief description of commands

- width– line length;

- solid- solid line;

- dotted– dotted line.

For a deeper understanding of styles, I recommend reading this one.

It is necessary to understand that in the process of making changes to the site code, the properties that determine the type of line, its thickness and color are listed separated by a space.

This method has several advantages:

A wide range of possibilities with which you can make almost any line.

Ease of making all necessary changes directly to the HTML code. This greatly simplifies the task for inexperienced site builders.

How to make a straight horizontal line using an HTML tag

The first thing I would like to draw your attention to is that this tag, despite all the subtleties and principles of html, does not have a closing tag. It can be used anywhere html code, between tags And

.

Tag attributes

- width– is responsible for the length of the line. Can be specified either as a percentage or in pixels.

- size– line thickness. Specified in pixels.

- color– defines the color of the line.

- align– an attribute responsible for line alignment. In turn, the team relates to him.

From the author: I salute you. The need to present several blocks on a web page in one line is a very common task that layout designers face. It occurs during the layout of almost every template, so in any case, we all need to know and apply the basic ways to change the behavior of blocks.

Before we look at the most common techniques, I would like to remember a little theory. Web page elements are divided into block and inline elements. And the difference between them is very simple - lowercase ones can be placed on one line, but block ones cannot. Of course, the differences don't end there, but this is the main difference. Blocks can already have padding at the top and bottom (lowercase ones do not), and more properties can be applied to them.

Basic ways to line up blocks in CSS

We won’t complicate anything, there are 3 main ways:

Convert blocks to inline elements. In this case, block properties are lost, so this option is almost never used

Make the necessary elements block-line. This is a special type in which the element retains its properties, but at the same time allows other blocks to be located nearby.

Make elements float using float properties.

Let's focus on these options. We will not consider Flexbox, table display and other aspects. So, let's say we have 3 subheadings.

Heading 1

Heading 2

Heading 3

Naturally, all css properties need to be written in separate file(style.css), which needs to be connected to the html document. In this file I will write a minimal style so that our subheadings are simply visible.

h3( background: #EEDDCD; )

h3 (

background : #EEDDCD;

Here they are on the page:

They behave like blocks. Each one is located on its own line, there are indents between them. If you wish, you can also set any internal padding and do whatever you want.

Let's convert it to lines and immediately add indents. To do this, the h3 selector needs to add the following properties:

display: inline; padding: 30px;

There are 2 main problems that arise when using this technique. The first is the minimum indentation. It is formed due to the fact that in the code there is one space between the blocks, which forms this indentation. If this problem needs solving, there are 2 main options:

In html, place the code of the required blocks in one line without spaces

Add a negative margin to the right of -4 pixels. That's how much one space takes.

The second problem is that if the elements have different heights, display problems may arise. All in all, best option- floating blocks. Instead of display: inline-block we write this:

Blocks in a line using the framework

I’ll say right away that if you are going to use any normal CSS framework (for example, Bootstrap), then everything is still much simpler. All the CSS code responsible for arranging the elements has already been written and all you have to do is set the correct classes. To do this, just learn the grid system, and you will be able to make multi-column responsive templates without much difficulty. At least it will be much easier than writing css from scratch.

Another challenge of writing code from scratch comes just when you need adaptive design. Of course, you can implement it yourself by owning media queries, but it will be much more difficult if you have a complex template.

For example, when you have big screens there should be 4 columns, on the middle ones - 3, and on mobile phones— 2. With the help of frameworks such as Bootstrap, or rather with the help of its grid, implementing something like this is a matter of just a few minutes.

Smoothly translating the topic to the Bootstrap framework, I will once again note that if you are faced with the task of laying out a complex adaptive template, then it is simply a sin not to use the grid. You don't even need to connect to do this. full version framework - you can customize it and stop there only what you really need.

You can learn how to work with the framework using . The theory is explained there, but most importantly, there is practice. You are making up 3 adaptive template and get great experience that will allow you to design websites to order or for yourself. And if you want to get acquainted with the advantages and capabilities of the framework for free, I suggest you look through our series of articles on Bootstrap, as well as on simple layout design. I wish you success in layout and website building in general.

When creating a page HTML design plays a significant role. Especially when we are talking about various symbols and decorative design: these little things help make the “language” of your page more accessible and clear, and also significantly change its perception and appearance generally. One of the most important elements for design is the horizontal line, and then we will learn in more detail how to work with it and how to make a horizontal line in html.

What is a horizontal line and what is it for?

A horizontal line in html is a page design element that performs a number of functions:

  1. Decorative. Helps add attractiveness to the page.
  2. Dividing. Promotes the effective separation of information of different meanings.
  3. Highlighting or emphasizing. Draws the attention of page guests to the necessary and most important information.

It is the horizontal line that is considered the most in an accessible way to implement a range of functions. It is very simple to create, and from the outside it looks very advantageous. By simple changes to the html code you can adjust:

  • length;
  • width;
  • color characteristics;
  • alignment along one edge or the other.

It is worth noting that the horizontal line refers to block elements. This means that it occupies a new line on the page, and the text that follows it will go below.

Creating a Horizontal Line in HTML

You can set a line using a simple tag – hr in triangular brackets. It is short for “Horizontal Rule” and sets classic external parameters. It differs from many others in that it does not need a closing tag and is able to exist independently. Change external characteristics element using additional values ​​in the tag:

  1. Length. If you do not want the length of the line to extend over the entire page, then you can set the desired size in pixels or percentages. This is done using the additional word “width” in the tag and the numerical length indicated after the “=” sign in quotation marks.

It looks like this. For example, if we need a length of 100 pixels, we set the following tag: hr width=”100″

  1. Alignment. Alignment is possible to the left or right edges, and also to the center. This characteristic only works if you have already specified the width parameter, since a line that spans the entire page cannot be aligned. For alignment, we set an additional attribute in the “align” tag and add a direction to it: center – for central, left – for left and right – for right alignment.

The finished tag in this case will look like this. For example, if we need to set the center alignment for a horizontal line 150 pixels long, then the finished tag will look like this: hr align=”center” width=”150″.

Note that "align", the alignment metric, is placed in 1st place, even though the attribute is dependent on the width metric.

  1. Width. You can also choose to specify the width, creating a bold or thin underline. This criterion does not depend on anything and can be used as an independent criterion without specifying length or alignment. For it, we use the size attribute in the tag and a numeric value equal to the desired width in pixels. The number is indicated in quotation marks after the size attribute and the “=” symbol.

Thus, if we need to create a line with a width of 15 pixels, we need to create the following tag: hr size=”15″.

  1. Color. It is also specified as an independent indicator. To change it, use the color attribute in combination with the name of the color in the form of a code or English language. The color is indicated in quotation marks after the “=” symbol.

Thus, the tag for a standard white line can be written in two ways: hr color=”#FFFFFF” or hr color=”white”

Black can be created using the code #000000.

  1. Put away shadow. If you need an element that does not contain a shadow, then you should use the noshade attribute in the tag. It can be used alone or in combination with other elements. A tag for a standard line using it will look like this: hr noshade

Creating a Horizontal Line Using Video

And if you want to receive information in a more visual format, then refer to the following video, which describes in detail the possibilities of working with a horizontal line.

Having determined the required dimensions of the horizontal line, you can design the website pages in such a way that the information is structured and visually competent. This helps visitors more easily perceive the information presented and makes your site stand out from others.

Task

Make a horizontal line on the page.

Solution

Horizontal lines are good for separating one block of text from another. Small text with horizontal lines at the top and bottom attracts more reader attention than regular text.

Using a tag


you can draw a horizontal line, the appearance of which depends on the attributes used, as well as the browser. The tag is a block element, so the line always starts with new line, and after it all elements are displayed on the next line. Thanks to the many tag attributes
the line created through this tag is easy to manage. If you also connect the power of styles, then adding a line to a document becomes a simple task.

Default line


displayed in gray color and with a volume effect. This type of line does not always suit the site design, so the desire of developers to change the color and other parameters of the line through styles is understandable. However, browsers have mixed approaches to this issue, which is why you will have to use several style properties at once. In particular, older versions of the browser Internet Explorer For line color, use the color property, and other browsers use background-color . But that’s not all, you must specify the line thickness (height property) to be non-zero and remove the frame around the line by setting the border property to none. By putting all the properties together for the hr selector, we get a universal solution for popular browsers (example 1).

Example 1: Horizontal line

HTML5 CSS 2.1 IE Cr Op Sa Fx

Horizontal line color


Text string




Result this example shown in Fig. 1.

Rice. 1. Colored horizontal line

Greetings to all readers. From time to time, masters are faced with the problem of how to make a horizontal or vertical line using HTML or using CSS. This is what I will tell you about today.

Lines in CSS

There are several ways to make lines. One of these ways is using CSS. Or rather, using Border. Let's look at an example.

And this is what will happen as a result.

Horizontal and vertical line using css.

Lines can be drawn in CSS using the Border operator. If you just need a rectangle with a fixed frame width, then you can simply use this operator and give it a value. For example border:5px solid #000000; will mean that the block borders have a width equal to 5 pixels of black color.

However, if you need to set not all boundaries, but only some, then you need to specify which boundaries are needed and what value each of them will have. These are the operators:

  • border-top – sets the value of the top border
  • border-bottom – sets the value of the bottom border
  • border-left – sets the value of the left border
  • border-right – sets the value of the right border.

Vertical and horizontal line in HTML

You can create lines in the HTML itself. To do this, you can use the hr tag.

In this case, a horizontal line will be drawn, one pixel high and full width.

But this tag can also be given some values.

  • Width– sets the line width value.
  • Color– sets the line color.
  • Align– sets alignment to left, center, right
  • Size– sets the line thickness value in pixels.

Using the hr tag, you can also set a vertical line. But in this case, you will have to resort to styles again.

In this case, a vertical line will be drawn one hundred pixels high, one pixel thick and five pixels indented.

Conclusion.

Well, now you know how you can set a vertical and horizontal line. Lines can be set as on regular sites, with using HTML, and set it on a site that uses a CMS, for example, WordPress, but in this case, you will need to switch to HTML mode.

Well, if you have any more questions, ask them in the comments.