The Artur solution creates a line, however if you increase the px value, it becomes clear that the line is still a gradient. This can be fixed using the start and end for the middle color as such:
p { background: linear-gradient(to bottom, white calc(50% - 1px), black calc(50% - 1px) calc(50% + 1px), white calc(50% + 1px)); }
The line will be twice as thick as the given px value (due to + px -px), therefore the above gives a horizontal 2px line through the center of the element.
source share