1

I am new to css, and I am trying to create a div element with a border, like
this

My HTML is below:

<div class="mystyle"> <h3>header message<h3> <p> this is my content</p> </div> 
2
  • 1
    Have you heard about <legend> and <fieldset>? Commented Sep 29, 2016 at 12:57
  • @DhavalMarthak no there Commented Sep 29, 2016 at 12:59

2 Answers 2

5

Use <fieldset> tag with <legend> inside it.

Try this code:

<fieldset> <legend>Example</legend> <div class="mystyle"> <h3>header message</h3> <p>this is my content</p> </div> </fieldset>

Sign up to request clarification or add additional context in comments.

1 Comment

it should work. can you create a fiddle with your problem?
0

We can do this with the help of 2 HTML tags:

 1.<fieldset></fieldset> and <legend></legend> tags. <legend> tag defines a caption for the <fieldset> tag and that caption comes with the border which you are looking for... 

Ex:

<fieldset> <legend>What is Lorem Ipsum?</legend> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> </fieldset> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.